Skip to content

Commit a5d9d0a

Browse files
committed
test(core): ✅ test behaviour of skip check functionality
1 parent 103c647 commit a5d9d0a

File tree

2 files changed

+32
-1
lines changed

2 files changed

+32
-1
lines changed

tests/unit/test_services.py

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
from rocrate_validator.models import ValidationSettings
2222
from rocrate_validator.rocrate import ROCrateMetadata
2323
from rocrate_validator.services import detect_profiles, get_profiles, validate
24-
from tests.ro_crates import InvalidMultiProfileROC, ValidROC
24+
from tests.ro_crates import InvalidMultiProfileROC, ValidROC, InvalidFileDescriptorEntity
2525

2626
# set up logging
2727
logger = logging.getLogger(__name__)
@@ -137,6 +137,33 @@ def test_disable_inherited_profiles_issue_reporting():
137137
"All reported issues should belong to the main profile when inherited profiles issue reporting is disabled"
138138

139139

140+
def test_skip_pycheck_on_workflow_ro_crate():
141+
# Set the rocrate_uri to the workflow testing RO-Crate
142+
crate_path = InvalidFileDescriptorEntity().invalid_conforms_to
143+
logger.debug("Validating a local RO-Crate: %s", crate_path)
144+
settings = ValidationSettings(rocrate_uri=crate_path)
145+
result = validate(settings)
146+
assert not result.passed(), \
147+
"The RO-Crate is expected to be invalid because of an incorrect conformsTo field and missing resources"
148+
assert len(result.failed_checks) == 2, "No failed checks expected when skipping the problematic check"
149+
assert any(check.identifier == "ro-crate-1.1_5.3" for check in result.failed_checks), \
150+
"Expected the check 'ro-crate-1.1_5.3' to fail"
151+
assert any(check.identifier == "ro-crate-1.1_12.1" for check in result.failed_checks), \
152+
"Expected the check 'ro-crate-1.1_12.1' to fail"
153+
154+
# Perform a new validation skipping specific checks
155+
settings.skip_checks = ["ro-crate-1.1_5.3", "ro-crate-1.1_12.1"]
156+
result = validate(settings)
157+
assert result.passed(), \
158+
"The RO-Crate should be valid when skipping the checks related to the invalid file descriptor entity"
159+
160+
# Ensure that the skipped checks are indeed skipped
161+
skipped_check_ids = {check.identifier for check in result.skipped_checks}
162+
# logger.error("Skipped checks: %s", result.skipped_checks)
163+
assert "ro-crate-1.1_5.3" in skipped_check_ids, "Expected check 'ro-crate-1.1_5.3' to be skipped"
164+
assert "ro-crate-1.1_12.1" in skipped_check_ids, "Expected check 'ro-crate-1.1_12.1' to be skipped"
165+
166+
140167
def test_valid_local_multi_profile_crate():
141168
# Set the rocrate_uri to the multi-profile RO-Crate
142169
crate_path = InvalidMultiProfileROC().invalid_multi_profile_crate

tests/unit/test_validation_settings.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,15 @@ def test_validation_settings_parse_dict():
2424
"requirement_severity": "RECOMMENDED",
2525
"enable_profile_inheritance": False,
2626
"disable_inherited_profiles_issue_reporting": True,
27+
"skip_checks": ["check1", "check2"]
2728
}
2829
settings = ValidationSettings.parse(settings_dict)
2930
assert str(settings.rocrate_uri) == "/path/to/data"
3031
assert settings.profiles_path == "/path/to/profiles"
3132
assert settings.requirement_severity == Severity.RECOMMENDED
3233
assert settings.enable_profile_inheritance is False
3334
assert settings.disable_inherited_profiles_issue_reporting is True
35+
assert settings.skip_checks == ["check1", "check2"]
3436

3537

3638
def test_validation_settings_parse_object():
@@ -40,13 +42,15 @@ def test_validation_settings_parse_object():
4042
requirement_severity=Severity.RECOMMENDED,
4143
enable_profile_inheritance=False,
4244
disable_inherited_profiles_issue_reporting=True,
45+
skip_checks=["check1", "check2"]
4346
)
4447
settings = ValidationSettings.parse(existing_settings)
4548
assert str(settings.rocrate_uri) == "/path/to/data"
4649
assert settings.profiles_path == "/path/to/profiles"
4750
assert settings.requirement_severity == Severity.RECOMMENDED
4851
assert settings.enable_profile_inheritance is False
4952
assert settings.disable_inherited_profiles_issue_reporting is True
53+
assert settings.skip_checks == ["check1", "check2"]
5054

5155

5256
def test_validation_settings_parse_invalid_type():

0 commit comments

Comments
 (0)