diff --git a/setup.cfg b/setup.cfg index d05f2acb1e8d5afafa5a1003c6da2dff0980c126..ae138a9ace0dcc6d88bb1f8fb46f77ac094f73a0 100644 --- a/setup.cfg +++ b/setup.cfg @@ -51,4 +51,4 @@ h5-crawler = spss = pandas[spss] rocrate = - rocrate @ git+https://github.com/salexan2001/ro-crate-py.git@f-automatic-dummy-ids + rocrate diff --git a/unittests/eln_files/PASTA.eln b/unittests/eln_files/PASTA.eln deleted file mode 100644 index 61866e7d5f57cb32191af6663be230153092e712..0000000000000000000000000000000000000000 Binary files a/unittests/eln_files/PASTA.eln and /dev/null differ diff --git a/unittests/eln_files/records-example.eln b/unittests/eln_files/records-example.eln index 09ed53fc179e80a240ab773247d6f9adee71b429..4907bcc4e88e2152fdf2675a50ca661b666c947d 100644 Binary files a/unittests/eln_files/records-example.eln and b/unittests/eln_files/records-example.eln differ diff --git a/unittests/test_rocrate_converter.py b/unittests/test_rocrate_converter.py index dc7cef9f6d396c73a2a285d3f60fd587863237ac..ebf585fb1ccbf245e597ba412ab414bbfdd80b6b 100644 --- a/unittests/test_rocrate_converter.py +++ b/unittests/test_rocrate_converter.py @@ -76,6 +76,12 @@ def eln_entities(basic_eln_converter): return entities +@pytest.mark.xfail( + reason="The example files for PASTA have not yet been updated in:" + "https://github.com/TheELNConsortium/TheELNFileFormat/tree/master/examples/PASTA" + "However, there was the announcement that these files are going to follow the" + "flattened structure soon: https://github.com/TheELNConsortium/TheELNFileFormat/issues/98" +) def test_load_pasta(basic_eln_converter): """ Test for loading the .eln example export from PASTA. @@ -99,7 +105,7 @@ def test_load_kadi4mat(basic_eln_converter): match = basic_eln_converter.match(f_k4mat) assert match is not None entities = basic_eln_converter.create_children(GeneralStore(), f_k4mat) - assert len(entities) == 10 + assert len(entities) == 17 assert isinstance(entities[0], ROCrateEntity) assert isinstance(entities[0].folder, str) assert isinstance(entities[0].entity, Entity) @@ -131,7 +137,7 @@ match_properties: match = ds2.match(eln_entities[1]) assert match is not None - assert match["dateCreated"] == "2024-08-21T12:07:45.115990+00:00" + assert match["dateCreated"] == "2024-11-19T13:44:35.476888+00:00" children = ds2.create_children(GeneralStore(), eln_entities[1]) assert len(children) == 8 @@ -193,7 +199,20 @@ def test_scanner(): assert len(rlist) == 1 assert isinstance(rlist[0], db.Record) assert rlist[0].name == "records-example" - assert rlist[0].description == "This is a sample record." + # This assertion was moved to a different test, see below: + # assert rlist[0].description == "This is a sample record." assert rlist[0].parents[0].name == "Dataset" assert rlist[0].get_property("keywords").value == "sample" assert rlist[0].get_property("dateModified").value == "2024-08-21T11:43:17.626965+00:00" + + +@pytest.mark.xfail( + reason="The description is no longer a simple string, but a reference to another record." + "The rocrate converter will be able to dereference this as soon as this feature is implemented:" + "https://gitlab.indiscale.com/caosdb/src/caosdb-crawler/-/issues/191" + "This test might need changes in the yaml definition." +) +def test_description_reference(): + rlist = scanner.scan_directory(os.path.join(UNITTESTDIR, "eln_files/"), + os.path.join(UNITTESTDIR, "eln_cfood.yaml")) + assert rlist[0].description == "This is a sample record." diff --git a/unittests/test_zipfile_converter.py b/unittests/test_zipfile_converter.py index 9bc8b8804e299387157869f0dc8b11a9c2a8c6f8..22e4f2eab90563f6639c2197346a6c11987a89c9 100644 --- a/unittests/test_zipfile_converter.py +++ b/unittests/test_zipfile_converter.py @@ -50,6 +50,12 @@ def converter_registry(): return converter_registry +@pytest.mark.xfail( + reason="The example files for PASTA have not yet been updated in:" + "https://github.com/TheELNConsortium/TheELNFileFormat/tree/master/examples/PASTA" + "However, there was the announcement that these files are going to follow the" + "flattened structure soon: https://github.com/TheELNConsortium/TheELNFileFormat/issues/98" +) def test_zipfile_converter(converter_registry): zipfile = File("PASTA.eln", os.path.join(UNITTESTDIR, "eln_files", "PASTA.eln")) zip_conv = ZipFileConverter(yaml.safe_load(""" @@ -77,3 +83,29 @@ match: ^PASTA$ assert isinstance(children[i], Directory) for i in range(2, 5): assert isinstance(children[i], File) + + +def test_zipfile_minimal(converter_registry): + zipfile = File("empty.zip", os.path.join(UNITTESTDIR, "zip_minimal", "empty.zip")) + zip_conv = ZipFileConverter(yaml.safe_load(""" +type: ZipFile +match: .*$ +"""), "TestZipFileConverter", converter_registry) + + match = zip_conv.match(zipfile) + assert match is not None + + children = zip_conv.create_children(GeneralStore(), zipfile) + assert len(children) == 2 + assert children[1].name == "empty.txt" + + dir_conv = DirectoryConverter(yaml.safe_load(""" +type: Directory +match: ^folder$ +"""), "TestDirectory", converter_registry) + match = dir_conv.match(children[0]) + assert match is not None + children = dir_conv.create_children(GeneralStore(), children[0]) + assert len(children) == 3 + for i in range(3): + assert isinstance(children[i], File) diff --git a/unittests/zip_minimal/empty.zip b/unittests/zip_minimal/empty.zip new file mode 100644 index 0000000000000000000000000000000000000000..3eb2cee755e1b0265b13b1ee8f31c2aa1abe62de Binary files /dev/null and b/unittests/zip_minimal/empty.zip differ