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

TST(converters): test for generating children of ROCrate entities

parent ccb65a96
No related branches found
No related tags found
2 merge requests!198REL: Release 0.10.0,!193ROCrate-Converter (also for .eln-files)
Pipeline #57208 failed
This commit is part of merge request !198. Comments created here will be created in the context of that merge request.
...@@ -39,7 +39,7 @@ from rocrate.model.entity import Entity ...@@ -39,7 +39,7 @@ from rocrate.model.entity import Entity
from caoscrawler.converters import (ELNFileConverter, ROCrateEntityConverter) from caoscrawler.converters import (ELNFileConverter, ROCrateEntityConverter)
from caoscrawler.scanner import load_definition from caoscrawler.scanner import load_definition
from caoscrawler.stores import GeneralStore from caoscrawler.stores import GeneralStore
from caoscrawler.structure_elements import ROCrateEntity, File from caoscrawler.structure_elements import ROCrateEntity, File, TextElement, DictElement
UNITTESTDIR = Path(__file__).parent UNITTESTDIR = Path(__file__).parent
...@@ -114,7 +114,33 @@ def test_match_rocrate_entities(eln_entities): ...@@ -114,7 +114,33 @@ def test_match_rocrate_entities(eln_entities):
type: ROCrateEntity type: ROCrateEntity
match_properties: match_properties:
"@id": \\./ "@id": \\./
datePublished: (?P<datePublished>.*)
"""), "TestELNConverter", converter_registry) """), "TestELNConverter", converter_registry)
match = ds1.match(eln_entities[0]) match = ds1.match(eln_entities[0])
assert match is not None assert match is not None
ds2 = ROCrateEntityConverter(yaml.safe_load("""
type: ROCrateEntity
match_type: CreativeWork
match_properties:
"@id": ro-crate-metadata.json
dateCreated: (?P<dateCreated>.*)
"""), "TestELNConverter", converter_registry)
match = ds2.match(eln_entities[0])
assert match is None
match = ds1.match(eln_entities[1])
assert match is None
match = ds2.match(eln_entities[1])
assert match is not None
assert match["dateCreated"] == "2024-08-21T12:07:45.115990+00:00"
children = ds2.create_children(GeneralStore(), eln_entities[1])
assert len(children) == 7
assert isinstance(children[0], TextElement)
assert children[0].name == "@id"
assert children[0].value == "ro-crate-metadata.json"
assert isinstance(children[5], DictElement)
assert children[5].value == {'@id': 'https://kadi.iam.kit.edu'}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment