diff --git a/unittests/cfood_simple_file.yml b/unittests/cfood_simple_file.yml new file mode 100644 index 0000000000000000000000000000000000000000..8e93ad8af55eeea7c8a5892222206186a6baf7e2 --- /dev/null +++ b/unittests/cfood_simple_file.yml @@ -0,0 +1,52 @@ +# This is only a scifolder test cfood with a limited functionality. +# The full scifolder cfood will be developed here: +# https://gitlab.indiscale.com/caosdb/src/crawler-cfoods/scifolder-cfood + +--- +metadata: + crawler-version: 0.3.1 +--- +Definitions: + type: Definitions + #include "description.yml" + +Data: # name of the converter + type: Directory + match: (.*) + subtree: + DataAnalysis: # name of the converter + type: Directory + match: DataAnalysis + subtree: &template + project_dir: # name of the first subtree element which is a converter + type: Directory + match: ((?P<date>[0-9]{4,4})_)?(?P<identifier>.*) + records: + Project: # this is an identifiable in this case + parents: + - Project # not needed as the name is equivalent + date: $date + identifier: ${identifier} + + subtree: + measurement: # new name for folders on the 3rd level + type: Directory + match: (?P<date>[0-9]{4,4}-[0-9]{2,2}-[0-9]{2,2})(_(?P<identifier>.*))? + records: + Measurement: + date: $date + identifier: $identifier + project: $Project + subtree: + README: + type: SimpleFile # this is a subclass of converter File + # function signature: GeneralStore, StructureElement + # preprocessors: custom.caosdb.convert_values + match: ^README\.md$ + # how to make match case insensitive? + records: + TestFile: + path: $README + file: $README + role: File + diff --git a/unittests/test_scanner.py b/unittests/test_scanner.py index f53fc5274a5ed6d589dc78d5bd94bc816c3a150e..55eae86e9f7c3093117a6698c046bc5ed7cee50a 100644 --- a/unittests/test_scanner.py +++ b/unittests/test_scanner.py @@ -332,3 +332,12 @@ def test_new_debug_tree(): "unittests/test_directories/examples_article") assert len(new_debug_tree[0]["matching_converters"]) == 1 # exactly one matches assert len(new_debug_tree[0]["matching_converters"][0]["subtree"]) == 4 + + +def test_new_debug_tree_files(): + new_debug_tree = [] + scan_directory(UNITTESTDIR / "test_directories" / "examples_article", + UNITTESTDIR / "cfood_simple_file.yml", + new_debug_tree=new_debug_tree) + assert True # The only purpose of this test is to check whether + # it is possible to create a File entity and set a path.