|
21 | 21 | from rocrate_validator.models import ValidationSettings |
22 | 22 | from rocrate_validator.rocrate import ROCrateMetadata |
23 | 23 | 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 |
25 | 25 |
|
26 | 26 | # set up logging |
27 | 27 | logger = logging.getLogger(__name__) |
@@ -137,6 +137,33 @@ def test_disable_inherited_profiles_issue_reporting(): |
137 | 137 | "All reported issues should belong to the main profile when inherited profiles issue reporting is disabled" |
138 | 138 |
|
139 | 139 |
|
| 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 | + |
140 | 167 | def test_valid_local_multi_profile_crate(): |
141 | 168 | # Set the rocrate_uri to the multi-profile RO-Crate |
142 | 169 | crate_path = InvalidMultiProfileROC().invalid_multi_profile_crate |
|
0 commit comments