diff --git a/tests/example.yml b/tests/example.yml deleted file mode 100644 index 324d7ba78d4c0669947c529d68dcf4254983dbbe..0000000000000000000000000000000000000000 --- a/tests/example.yml +++ /dev/null @@ -1,32 +0,0 @@ - -experiment-directory: - type: directory #type defines that certain values are set; e.g. dir name - match: ".*" - recordtypes: - Experiment: - properties: - date: $date #in order to set property values, keys from this dict can be used - super: something.$date - valuegenerators: - - datepattern: - regexp: "8\d" - key: date #the value is stored under the key in the dict of this level - childrengenerators: - create_children_from_directory - subtree: - readme-file: - match: "README.md" - type: file - recordtypes: - Experiment: - properties: - responsible: responsible - valuegenerators: - - jsonloader: - regexp: "8\d" - value: date - - - - - diff --git a/tests/test_crawl.py b/tests/test_crawl.py deleted file mode 100644 index 8bc4d14f3884be1cb8d0e76192ad652b2668837f..0000000000000000000000000000000000000000 --- a/tests/test_crawl.py +++ /dev/null @@ -1,179 +0,0 @@ -#!/usr/bin/env python3 -# encoding: utf-8 -# -# ** header v3.0 -# This file is a part of the CaosDB Project. -# -# Copyright (C) 2021 Henrik tom Wörden -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU Affero General Public License as -# published by the Free Software Foundation, either version 3 of the -# License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Affero General Public License for more details. -# -# You should have received a copy of the GNU Affero General Public License -# along with this program. If not, see <https://www.gnu.org/licenses/>. -# -# ** end header -# - -""" -This file tests the behavoir of the crawler using small definitions and yml -structures. - -Dictionaries in the yaml are StructureElements. Key value pairs of the -dictionary are transfered to the value dict of the StructureElement. -""" - -import unittest - - -class BasicExperimentTest(unittest.TestCase): - # def setUp(self): - - def test_single(self): - # There is one dictionary, that is treated entirely as an experiment - structure = """ -stuff: 5 -""" - definition = """ -experiment: - type: dictionary - match: always - recordtypes: - Experiment: - properties: - stuff: $stuff """ - result = crawl() # dummy line - # 1 record - assert len(result) == 1 - # only parent is experiment - assert len(result[0].parents) == 1 - self.assertEqual(result[0].parents, "Experiment") - # name is set correctly - self.assertEqual(result[0].name, "cool-exp") - - def test_multiple(self): - # multiple dicts that each shall represent an experiment - structure = """ -cool-exp: - stuff: 5 -second-exp: -another-exp: - stuff: 5 -""" - # The outermost dictionary does not represent an entity. Therefore we - # need an additional level that creates child-nodes for each - # experiment. - definition = """ -toplevel: - type: dictionary - match: ".*" - subtree: - experiment: - type: dictionary - match: ".*" - recordtypes: - Experiment: - properties: - name: $name - stuff: $stuff """ - result = crawl() # dummy line - # 1 record - assert len(result) == 3 - - for r in result: - # only parent is experiment - assert len(r.parents) == 1 - self.assertEqual(r.parents, "Experiment") - # names are set correctly - self.assertTrue( - r.name in ["cool-exp", "second-exp", "another-exp"]) - - # second-exp shall not have a value for stuff - - if r.name == "second-exp": - self.assertEqual(r.get_property("stuff"), None) - - def test_three_level(self): - # multiple dicts that each shall represent an experiment - structure = """ -inter1: - cool-exp: - stuff: 5 -inter2: - second-exp: - another-exp: - stuff: 5 -""" - # The two outermost dictionaries do not represent an entity. We want to - # use the names of the intermediate levels in the Records. - definition = """ -toplevel: - type: dictionary - match: ".*" - subtree: - interlevel: - type: dictionary - match: ".*" - subtree: - experiment: - type: dictionary - match: ".*" - recordtypes: - Experiment: - properties: - name: $name - intermediate: $interlevel.name - stuff: $stuff """ - result = crawl() # dummy line - # 1 record - assert len(result) == 3 - - for r in result: - # only parent is experiment - assert len(r.parents) == 1 - self.assertEqual(r.parents, "Experiment") - # names are set correctly - self.assertTrue( - r.name in ["cool-exp", "second-exp", "another-exp"]) - - # second-exp shall not have a value for stuff - - if r.name == "second-exp": - self.assertEqual(r.get_property("stuff"), None) - - def test_three_level(self): - definition = """ -experiment: - type: dictionary - match: ".*" - recordtypes: - Experiment: - properties: - name: $date #in order to set property values, keys from this dict can be used - valuegenerators: - childrengenerators: - create_children_from_dictionaries - subtree: -""" - definition = """ -toplevel: - type: dictionary - match: ".*" - subtree: - experiment: - type: dictionary - match: ".*" - recordtypes: - Experiment: - properties: - stuff: $stuff - valuegenerators: - childrengenerators: - subtree: """ diff --git a/tests/test_functions.py b/tests/test_functions.py deleted file mode 100644 index 3e9a22b371a9ec8d9337d115805e509e9fca72c0..0000000000000000000000000000000000000000 --- a/tests/test_functions.py +++ /dev/null @@ -1,5 +0,0 @@ -#!/bin/python -# Tests for main functions of crawler -# A. Schlemmer, 07/2021 - -#from newcrawler import match_complete