Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
4e45698
First test for ld_container
Jul 11, 2025
f7ef65d
Add license information
Jul 14, 2025
ccec2ec
Test ld_container add_context
Jul 24, 2025
04a727d
Refactor tests to class
Jul 24, 2025
6cb305b
Test representation methods
Jul 24, 2025
14373f8
Correct container parameters
Jul 31, 2025
5e8e693
Fix method name and test convertion methods
Jul 31, 2025
4847d66
Remove docstring from closed issue
Jul 31, 2025
e2995b3
Add dependency for tests.
led02 Jul 31, 2025
8da44cb
Adapt test of _To_expanded_json.
led02 Jul 31, 2025
f0148a5
Add test helpers that provide JSON-LD data.
led02 Aug 1, 2025
2dfed2d
Add documentation to helpers.
led02 Aug 1, 2025
a527fb0
Add test for helpers.
led02 Aug 1, 2025
2fbe1e0
Using mock_document for setup.
led02 Aug 1, 2025
e362b15
Remove test for pyld internals.
led02 Aug 1, 2025
8b2e59f
Switch test to use mock_context from helpers.
led02 Aug 1, 2025
4b8c3b7
Added more tests.
led02 Aug 1, 2025
3bceb49
Restructured tests for ld_container (type conversions).
led02 Aug 1, 2025
ef2eb70
Update poetry lock to get CI running.
led02 Aug 1, 2025
af21ace
Fix linting errors.
led02 Aug 1, 2025
8b4f9a3
Delete tests for old data model.
led02 Aug 1, 2025
d825217
Disable tests that fail due to missing old data model.
led02 Aug 1, 2025
d9761ab
Fix test for mock document.
led02 Aug 1, 2025
9113c7b
Fix mock document.
led02 Aug 1, 2025
df5b0ef
Silence flake8 on inactive tests.
led02 Aug 1, 2025
4fe4ffb
Silence flake8 on inactive tests more agressively.
led02 Aug 1, 2025
d577aab
Revert "Silence flake8 on inactive tests more agressively."
led02 Aug 1, 2025
b432ccf
Revert "Silence flake8 on inactive tests."
led02 Aug 1, 2025
6a10129
Revert "Disable tests that fail due to missing old data model."
led02 Aug 1, 2025
de09fdb
Revert "Delete tests for old data model."
led02 Aug 1, 2025
0edc582
Merge remote-tracking branch 'origin/refactor/data-model' into refact…
led02 Aug 5, 2025
68aec7f
Update poetry.lock for added test dependencies.
led02 Aug 5, 2025
ea08105
Add missing dependencies again.
led02 Aug 5, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
110 changes: 106 additions & 4 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ dependencies = [
"pydantic-settings>=2.1.0, <3.0.0",
"requests-oauthlib>=2.0.0, <3.0.0",
"pynacl>=1.5.0, <2.0.0",
"rdflib (>=7.1.4,<8.0.0)",
"schemaorg (>=0.1.1,<0.2.0)",
]
requires-python = ">=3.10, <4.0.0"

Expand Down Expand Up @@ -76,6 +78,7 @@ pytest-cov = "^3.0.0"
taskipy = "^1.10.3"
flake8 = "^5.0.4"
requests-mock = "^1.10.0"
pytest-httpserver = "^1.1.3"

# Packages for developers for creating documentation
[tool.poetry.group.docs]
Expand Down
2 changes: 1 addition & 1 deletion src/hermes/model/types/ld_container.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def __init__(self, data, *, parent=None, key=None, index=None, context=None):
else:
self.active_ctx = parent.active_ctx
else:
self.active_ctx = self.ld_proc.inital_ctx(
self.active_ctx = self.ld_proc.initial_ctx(
self.full_context,
{"documentLoader": bundled_loader}
)
Expand Down
2 changes: 1 addition & 1 deletion src/hermes/model/types/pyld_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ def expand_iri(self, active_ctx: t.Any, short_iri: str) -> str:
def compact_iri(self, active_ctx: t.Any, long_iri: str) -> str:
return self._compact_iri(active_ctx, long_iri, vocab=True)

def inital_ctx(self, local_ctx, options=None):
def initial_ctx(self, local_ctx, options=None):
return self.process_context(self._INITIAL_CONTEXT, local_ctx, options or {})

@classmethod
Expand Down
5 changes: 5 additions & 0 deletions test/hermes_test/model/types/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# SPDX-FileCopyrightText: 2025 German Aerospace Center (DLR)
#
# SPDX-License-Identifier: Apache-2.0

# SPDX-FileContributor: Sophie Kernchen
88 changes: 88 additions & 0 deletions test/hermes_test/model/types/conftest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
# SPDX-FileCopyrightText: 2025 German Aerospace Center (DLR)
#
# SPDX-License-Identifier: Apache-2.0

from datetime import datetime

import pytest


class MockDocument:
"""
Helper that provides valid JSON-LD data.
"""

@classmethod
def vocabulary(cls, base_url: str = "http://spam.eggs/") -> dict:
"""
Retrieve the vocabulary used for the document.

:param base_url: Optional base URL to use for IRIs in the vocabulary.
:returns: A JSON-LD vocabulary usable in as document context.
"""
return {
"spam": {"@id": f"{base_url}spam"},
"ham": {"@id": f"{base_url}ham", "@type": "@id"},
"eggs": {"@id": f"{base_url}eggs", "@container": "@list"},
"use_until": {"@id": f"{base_url}use_until", "@type": "http://schema.org/DateTime"},

"Egg": {"@id": f"{base_url}Egg"},
}

@classmethod
def compact(cls, base_url: str = "http://spam.eggs/", embed_vocabulary: bool = True) -> dict:
"""
Get compact representation of the example document.

:param base_url: Optional base URL used to generate the context.
:param embed_vocabulary: Optional switch to indicate whether the vocabulary should be embedded in the context
or only refrenced by the base url.
:returns: The rendered compact document.
"""
return {
"@context": cls.vocabulary(base_url) if embed_vocabulary else base_url,

"spam": "bacon",
"ham": f"{base_url}identifier",
"eggs": [
{"@type": "Egg", "use_until": datetime(2024, 4, 20, 16, 20).isoformat()},
{"@type": "Egg", "use_until": datetime(2026, 12, 31, 23, 59, 59).isoformat()},
]
}

@classmethod
def expanded(cls, base_url: str = "http://spam.eggs/") -> list[dict]:
"""
Get expanded representation of the example document.

:param base_url: Optional base URL to use for IRIs.
:returns: The rendered expanded document.
"""
return [{
f"{base_url}spam": [{"@value": "bacon"}],
f"{base_url}ham": [{"@id": f"{base_url}identifier"}],
f"{base_url}eggs": [{"@list": [
{
"@type": [f"{base_url}Egg"],
f"{base_url}use_until": [
{"@type": "http://schema.org/DateTime", "@value": "2024-04-20T16:20:00"}
],
},
{
"@type": [f"{base_url}Egg"],
f"{base_url}use_until": [
{"@type": "http://schema.org/DateTime", "@value": "2026-12-31T23:59:59"}
],
}
]}]
}]


@pytest.fixture
def mock_context():
return MockDocument.vocabulary()


@pytest.fixture
def mock_document():
return MockDocument
Loading
Loading