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

TST: fixed tests due to changes to rocrate feature

parent c3a6f565
No related branches found
No related tags found
2 merge requests!217TST: Make NamedTemporaryFiles Windows-compatible,!215Fix issues in rocrate support
Pipeline #60454 passed
...@@ -200,12 +200,16 @@ class ROCrateEntityConverter(Converter): ...@@ -200,12 +200,16 @@ class ROCrateEntityConverter(Converter):
# This is - according to the standard - only allowed, if it's flat, i.e. # This is - according to the standard - only allowed, if it's flat, i.e.
# it contains a single element with key == "@id" and the id as value which # it contains a single element with key == "@id" and the id as value which
# is supposed to be dereferenced: # is supposed to be dereferenced:
if not (len(value) == 1 and "@id" in eprops): if not (len(value) == 1 and "@id" in value):
raise RuntimeError("The JSON-LD is not flat.") raise RuntimeError("The JSON-LD is not flat.")
children.append(
ROCrateEntity(element.folder, element.entity.crate.dereference(
value["@id"])))
# TODO: tests missing! # TODO: tests missing!
dereferenced = element.entity.crate.dereference(value["@id"])
if dereferenced is not None:
children.append(
ROCrateEntity(element.folder, dereferenced))
else:
# This is just an external ID and will be added as simple DictElement
children.append(convert_basic_element(value, name))
else: else:
children.append(convert_basic_element(value, name)) children.append(convert_basic_element(value, name))
......
...@@ -144,8 +144,8 @@ match_properties: ...@@ -144,8 +144,8 @@ match_properties:
assert isinstance(children[0], TextElement) assert isinstance(children[0], TextElement)
assert children[0].name == "@id" assert children[0].name == "@id"
assert children[0].value == "ro-crate-metadata.json" assert children[0].value == "ro-crate-metadata.json"
assert isinstance(children[5], DictElement) assert isinstance(children[5], ROCrateEntity)
assert children[5].value == {'@id': 'https://kadi.iam.kit.edu'} assert children[5].name == "https://kadi.iam.kit.edu"
def test_file(eln_entities): def test_file(eln_entities):
...@@ -184,13 +184,20 @@ match_properties: ...@@ -184,13 +184,20 @@ match_properties:
assert match is not None assert match is not None
children = ds_parts.create_children(GeneralStore(), ent_parts) children = ds_parts.create_children(GeneralStore(), ent_parts)
# Number of children = number of properties + number of parts +
# number of variables measured + number of files
assert len(children) == (len(ent_parts.entity.properties()) +
len(ent_parts.entity.properties()["hasPart"]) +
len(ent_parts.entity.properties()["variableMeasured"]))
# Number of children = number of properties + number of parts:
assert len(children) == len(ent_parts.entity.properties()) + 4
entity_children = [f for f in children if isinstance(f, ROCrateEntity)] entity_children = [f for f in children if isinstance(f, ROCrateEntity)]
assert len(entity_children) == 4 assert len(entity_children) == 13
file_counter = 0
for f in entity_children: for f in entity_children:
assert isinstance(f.entity, rocrate.model.file.File) if isinstance(f.entity, rocrate.model.file.File):
file_counter += 1
assert file_counter == 4
def test_scanner(): def test_scanner():
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment