Skip to content
Snippets Groups Projects
Commit c3a6f565 authored by Alexander Schlemmer's avatar Alexander Schlemmer
Browse files

Merge branch 'f-reenable-rocrate-dep' into f-fix-rocrate

parents e0866790 66595e57
No related branches found
No related tags found
2 merge requests!217TST: Make NamedTemporaryFiles Windows-compatible,!215Fix issues in rocrate support
Pipeline #60233 failed
...@@ -51,4 +51,4 @@ h5-crawler = ...@@ -51,4 +51,4 @@ h5-crawler =
spss = spss =
pandas[spss] pandas[spss]
rocrate = rocrate =
rocrate @ git+https://github.com/salexan2001/ro-crate-py.git@f-automatic-dummy-ids rocrate
File deleted
No preview for this file type
...@@ -76,6 +76,12 @@ def eln_entities(basic_eln_converter): ...@@ -76,6 +76,12 @@ def eln_entities(basic_eln_converter):
return entities 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): def test_load_pasta(basic_eln_converter):
""" """
Test for loading the .eln example export from PASTA. Test for loading the .eln example export from PASTA.
...@@ -99,7 +105,7 @@ def test_load_kadi4mat(basic_eln_converter): ...@@ -99,7 +105,7 @@ def test_load_kadi4mat(basic_eln_converter):
match = basic_eln_converter.match(f_k4mat) match = basic_eln_converter.match(f_k4mat)
assert match is not None assert match is not None
entities = basic_eln_converter.create_children(GeneralStore(), f_k4mat) 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], ROCrateEntity)
assert isinstance(entities[0].folder, str) assert isinstance(entities[0].folder, str)
assert isinstance(entities[0].entity, Entity) assert isinstance(entities[0].entity, Entity)
...@@ -131,7 +137,7 @@ match_properties: ...@@ -131,7 +137,7 @@ match_properties:
match = ds2.match(eln_entities[1]) match = ds2.match(eln_entities[1])
assert match is not None 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]) children = ds2.create_children(GeneralStore(), eln_entities[1])
assert len(children) == 8 assert len(children) == 8
...@@ -193,7 +199,20 @@ def test_scanner(): ...@@ -193,7 +199,20 @@ def test_scanner():
assert len(rlist) == 1 assert len(rlist) == 1
assert isinstance(rlist[0], db.Record) assert isinstance(rlist[0], db.Record)
assert rlist[0].name == "records-example" 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].parents[0].name == "Dataset"
assert rlist[0].get_property("keywords").value == "sample" assert rlist[0].get_property("keywords").value == "sample"
assert rlist[0].get_property("dateModified").value == "2024-08-21T11:43:17.626965+00:00" 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."
...@@ -50,6 +50,12 @@ def converter_registry(): ...@@ -50,6 +50,12 @@ def converter_registry():
return 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): def test_zipfile_converter(converter_registry):
zipfile = File("PASTA.eln", os.path.join(UNITTESTDIR, "eln_files", "PASTA.eln")) zipfile = File("PASTA.eln", os.path.join(UNITTESTDIR, "eln_files", "PASTA.eln"))
zip_conv = ZipFileConverter(yaml.safe_load(""" zip_conv = ZipFileConverter(yaml.safe_load("""
...@@ -77,3 +83,29 @@ match: ^PASTA$ ...@@ -77,3 +83,29 @@ match: ^PASTA$
assert isinstance(children[i], Directory) assert isinstance(children[i], Directory)
for i in range(2, 5): for i in range(2, 5):
assert isinstance(children[i], File) 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)
File added
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment