Skip to content

Commit 7ebd022

Browse files
committed
fix: add missing sync for sparql, shacl test suites
- sparql_test_suites <-> test_suites_sparql - shacl_test_suites <-> test_suites_shacl This also fixes some tests that rely on these prerequisite validation data.
1 parent abe6e4a commit 7ebd022

1 file changed

Lines changed: 83 additions & 0 deletions

File tree

src/ted_sws/core/model/transform.py

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
TestDataCollectionAsset,
2222
SPARQLTestCollectionAsset,
2323
SHACLTestCollectionAsset,
24+
SHACLShapesCollectionAsset,
2425
TestResultCollectionAsset,
2526
TechnicalMappingCollectionAsset,
2627
VocabularyMappingCollectionAsset,
@@ -29,6 +30,9 @@
2930
RMLMappingFileAsset,
3031
VocabularyMappingFileAsset,
3132
TestDataFileAsset,
33+
SPARQLQueryFileAsset,
34+
SHACLShapesFileAsset,
35+
SHACLShapesResultQueryFileAsset,
3236
)
3337
from mapping_suite_sdk.mapping_package_v3.models.mapping_package_v3_metadata_jsonld import (
3438
MappingPackageV3MetadataJSONLD,
@@ -338,6 +342,47 @@ def _populate_mssdk_from_legacy(self) -> None:
338342
mssdk_version="3.0.0"
339343
)
340344

345+
# Populate test_suites_sparql from legacy sparql_test_suites
346+
if not self.test_suites_sparql and self.sparql_test_suites:
347+
self.test_suites_sparql = [
348+
SPARQLTestCollectionAsset(
349+
path=Path(f"validation/sparql/{suite.identifier}"),
350+
files=[
351+
SPARQLQueryFileAsset(
352+
path=Path(f"validation/sparql/{suite.identifier}/{test.file_name}"),
353+
content=test.file_content
354+
)
355+
for test in suite.sparql_tests
356+
]
357+
)
358+
for suite in self.sparql_test_suites
359+
]
360+
361+
# Populate test_suites_shacl from legacy shacl_test_suites
362+
if self.test_suites_shacl is None and self.shacl_test_suites:
363+
shacl_collections = [
364+
SHACLShapesCollectionAsset(
365+
path=Path(f"validation/shacl/{suite.identifier}"),
366+
files=[
367+
SHACLShapesFileAsset(
368+
path=Path(f"validation/shacl/{suite.identifier}/{test.file_name}"),
369+
content=test.file_content
370+
)
371+
for test in suite.shacl_tests
372+
]
373+
)
374+
for suite in self.shacl_test_suites
375+
]
376+
if shacl_collections:
377+
self.test_suites_shacl = SHACLTestCollectionAsset(
378+
path=Path("validation/shacl"),
379+
shacl_collections=shacl_collections,
380+
shacl_result_query=SHACLShapesResultQueryFileAsset(
381+
path=Path("validation/shacl/shacl_result_query.rq"),
382+
content="# Placeholder SHACL result query"
383+
)
384+
)
385+
341386
def _populate_legacy_from_mssdk(self) -> None:
342387
"""Populate legacy pipeline fields from MSSDK v3 fields when needed."""
343388
if self.metadata:
@@ -451,3 +496,41 @@ def _populate_legacy_from_mssdk(self) -> None:
451496
)
452497
# Clear MSSDK v2 test_data_suites after populating
453498
self.test_data_suites = []
499+
500+
# Populate legacy sparql_test_suites from test_suites_sparql
501+
if not self.sparql_test_suites and self.test_suites_sparql:
502+
self.sparql_test_suites = [
503+
SPARQLTestSuite(
504+
identifier=suite.path.name if suite.path else f"sparql_suite_{idx}",
505+
sparql_tests=[
506+
FileResource(
507+
file_name=file.path.name,
508+
file_content=file.content,
509+
original_name=file.path.name
510+
)
511+
for file in suite.files
512+
]
513+
)
514+
for idx, suite in enumerate(self.test_suites_sparql)
515+
]
516+
# Clear MSSDK test_suites_sparql after populating
517+
self.test_suites_sparql = []
518+
519+
# Populate legacy shacl_test_suites from test_suites_shacl
520+
if not self.shacl_test_suites and self.test_suites_shacl:
521+
self.shacl_test_suites = [
522+
SHACLTestSuite(
523+
identifier=collection.path.name if collection.path else f"shacl_suite_{idx}",
524+
shacl_tests=[
525+
FileResource(
526+
file_name=file.path.name,
527+
file_content=file.content,
528+
original_name=file.path.name
529+
)
530+
for file in collection.files
531+
]
532+
)
533+
for idx, collection in enumerate(self.test_suites_shacl.shacl_collections)
534+
]
535+
# Clear MSSDK test_suites_shacl after populating
536+
self.test_suites_shacl = None

0 commit comments

Comments
 (0)