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

TST(converter): first test for rocrate entity converter

parent 857b02f0
No related branches found
No related tags found
2 merge requests!198REL: Release 0.10.0,!193ROCrate-Converter (also for .eln-files)
Pipeline #57207 failed
......@@ -36,7 +36,7 @@ from pathlib import Path
from rocrate.rocrate import ROCrate
from rocrate.model.entity import Entity
from caoscrawler.converters import (ELNFileConverter,)
from caoscrawler.converters import (ELNFileConverter, ROCrateEntityConverter)
from caoscrawler.scanner import load_definition
from caoscrawler.stores import GeneralStore
from caoscrawler.structure_elements import ROCrateEntity, File
......@@ -51,6 +51,10 @@ def converter_registry():
"ELNFile": {
"converter": "ELNFileConverter",
"package": "caoscrawler.converters"},
"ROCrateEntity": {
"converter": "ROCrateEntityConverter",
"package": "caoscrawler.converters",
}
}
for key, value in converter_registry.items():
......@@ -67,6 +71,15 @@ match: .*\\.eln
"""), "TestELNConverter", converter_registry)
@pytest.fixture
def eln_entities(basic_eln_converter):
f_k4mat = File("records-example.eln",
os.path.join(UNITTESTDIR, "eln_files", "records-example.eln"))
store = GeneralStore()
entities = basic_eln_converter.create_children(store, f_k4mat)
return entities
def test_load_pasta(basic_eln_converter):
"""
Test for loading the .eln example export from PASTA.
......@@ -85,7 +98,8 @@ def test_load_kadi4mat(basic_eln_converter):
"""
Test for loading the .eln example export from PASTA.
"""
f_k4mat = File("records-example.eln", os.path.join(UNITTESTDIR, "eln_files", "records-example.eln"))
f_k4mat = File("records-example.eln",
os.path.join(UNITTESTDIR, "eln_files", "records-example.eln"))
match = basic_eln_converter.match(f_k4mat)
assert match is not None
entities = basic_eln_converter.create_children(GeneralStore(), f_k4mat)
......@@ -95,5 +109,12 @@ def test_load_kadi4mat(basic_eln_converter):
assert isinstance(entities[0].entity, Entity)
def test_match_rocrate_element(basic_eln_converter):
pass
def test_match_rocrate_entities(eln_entities):
ds1 = ROCrateEntityConverter(yaml.safe_load("""
type: ROCrateEntity
match_properties:
"@id": \\./
"""), "TestELNConverter", converter_registry)
match = ds1.match(eln_entities[0])
assert match is not None
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment