|
21 | 21 | TestDataCollectionAsset, |
22 | 22 | SPARQLTestCollectionAsset, |
23 | 23 | SHACLTestCollectionAsset, |
| 24 | + SHACLShapesCollectionAsset, |
24 | 25 | TestResultCollectionAsset, |
25 | 26 | TechnicalMappingCollectionAsset, |
26 | 27 | VocabularyMappingCollectionAsset, |
|
29 | 30 | RMLMappingFileAsset, |
30 | 31 | VocabularyMappingFileAsset, |
31 | 32 | TestDataFileAsset, |
| 33 | + SPARQLQueryFileAsset, |
| 34 | + SHACLShapesFileAsset, |
| 35 | + SHACLShapesResultQueryFileAsset, |
32 | 36 | ) |
33 | 37 | from mapping_suite_sdk.mapping_package_v3.models.mapping_package_v3_metadata_jsonld import ( |
34 | 38 | MappingPackageV3MetadataJSONLD, |
@@ -338,6 +342,47 @@ def _populate_mssdk_from_legacy(self) -> None: |
338 | 342 | mssdk_version="3.0.0" |
339 | 343 | ) |
340 | 344 |
|
| 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 | + |
341 | 386 | def _populate_legacy_from_mssdk(self) -> None: |
342 | 387 | """Populate legacy pipeline fields from MSSDK v3 fields when needed.""" |
343 | 388 | if self.metadata: |
@@ -451,3 +496,41 @@ def _populate_legacy_from_mssdk(self) -> None: |
451 | 496 | ) |
452 | 497 | # Clear MSSDK v2 test_data_suites after populating |
453 | 498 | 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