|
16 | 16 | import os |
17 | 17 |
|
18 | 18 | import pytest |
| 19 | +from requirements.shacl.checks import SHACLCheck |
19 | 20 |
|
20 | 21 | from rocrate_validator.constants import DEFAULT_PROFILE_IDENTIFIER |
21 | | -from rocrate_validator.errors import (DuplicateRequirementCheck, |
22 | | - InvalidProfilePath, |
23 | | - ProfileSpecificationError) |
24 | | -from rocrate_validator.models import (Profile, ValidationContext, |
25 | | - ValidationSettings, Validator) |
| 22 | +from rocrate_validator.errors import DuplicateRequirementCheck, InvalidProfilePath, ProfileSpecificationError |
| 23 | +from rocrate_validator.models import Profile, ValidationContext, ValidationSettings, Validator |
26 | 24 | from tests.ro_crates import InvalidFileDescriptorEntity, ValidROC |
27 | 25 |
|
28 | 26 | # set up logging |
@@ -297,6 +295,32 @@ def test_load_valid_profile_with_override_on_inherited_profile(fake_profiles_pat |
297 | 295 | assert len(requirements_checks) == 3, "The number of requirements should be 2" |
298 | 296 |
|
299 | 297 |
|
| 298 | +def test_zero_shape_target_profile_triggers_pyshacl_run(fake_profiles_path: str): |
| 299 | + """Regression test for the 0-shape profile bug: |
| 300 | + when the target profile has no SHACL checks of its own, |
| 301 | + Validator must still drive a single pyshacl run |
| 302 | + on the merged shapes graph so inherited shapes get evaluated. |
| 303 | + Without the fix in `Validator.__ensure_target_shacl_run__`, |
| 304 | + no SHACLCheck would be recorded as executed for the wrapper target.""" |
| 305 | + |
| 306 | + settings = ValidationSettings(**{ |
| 307 | + "profiles_path": fake_profiles_path, |
| 308 | + "profile_identifier": "c-wrapper", |
| 309 | + "rocrate_uri": ValidROC().wrroc_paper, |
| 310 | + "enable_profile_inheritance": True, |
| 311 | + "allow_requirement_check_override": True, |
| 312 | + "disable_check_for_duplicates": True, |
| 313 | + }) |
| 314 | + result = Validator(settings).validate() |
| 315 | + |
| 316 | + executed_shacl = [c for c in result.executed_checks |
| 317 | + if isinstance(c, SHACLCheck)] |
| 318 | + assert executed_shacl, ( |
| 319 | + "Expected at least one inherited SHACLCheck to be executed for the " |
| 320 | + "c-wrapper target. None recorded — the zero-shape pyshacl run was " |
| 321 | + "skipped.") |
| 322 | + |
| 323 | + |
300 | 324 | def test_profile_parents(check_overriding_profiles_path: str): |
301 | 325 | """Test the order of the loaded profiles.""" |
302 | 326 | logger.debug("The profiles path: %r", check_overriding_profiles_path) |
|
0 commit comments