diff --git a/rocrate_validator/profiles/five-safes-crate/0_workflow_run_inference.ttl b/rocrate_validator/profiles/five-safes-crate/0_workflow_run_inference.ttl index 2cfafdd79..d496bd324 100644 --- a/rocrate_validator/profiles/five-safes-crate/0_workflow_run_inference.ttl +++ b/rocrate_validator/profiles/five-safes-crate/0_workflow_run_inference.ttl @@ -12,7 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -@prefix ro-crate: . +@prefix ro-crate: . @prefix rdf: . @prefix schema: . @prefix sh: . diff --git a/rocrate_validator/profiles/five-safes-crate/10_outputs.ttl b/rocrate_validator/profiles/five-safes-crate/10_outputs.ttl index 66b10b6a1..3e3dbb5e3 100644 --- a/rocrate_validator/profiles/five-safes-crate/10_outputs.ttl +++ b/rocrate_validator/profiles/five-safes-crate/10_outputs.ttl @@ -13,7 +13,7 @@ # limitations under the License. @prefix ro: <./> . -@prefix ro-crate: . +@prefix ro-crate: . @prefix five-safes-crate: . @prefix rdf: . @prefix schema: . diff --git a/rocrate_validator/profiles/five-safes-crate/11_workflow_execution_phase.ttl b/rocrate_validator/profiles/five-safes-crate/11_workflow_execution_phase.ttl index 6eab5680b..c5b813e26 100644 --- a/rocrate_validator/profiles/five-safes-crate/11_workflow_execution_phase.ttl +++ b/rocrate_validator/profiles/five-safes-crate/11_workflow_execution_phase.ttl @@ -13,7 +13,7 @@ # limitations under the License. @prefix ro: <./> . -@prefix ro-crate: . +@prefix ro-crate: . @prefix five-safes-crate: . @prefix rdf: . @prefix schema: . @@ -75,7 +75,7 @@ five-safes-crate:WorkflowexecutionObjectHasEndTimeIfEnded a sh:SPARQLTarget ; sh:select """ PREFIX schema: - PREFIX rocrate: + PREFIX rocrate: SELECT ?this WHERE { @@ -115,7 +115,7 @@ five-safes-crate:WorkflowexecutionObjectHasStartTimeIfBegun a sh:SPARQLTarget ; sh:select """ PREFIX schema: - PREFIX rocrate: + PREFIX rocrate: SELECT ?this WHERE { diff --git a/rocrate_validator/profiles/five-safes-crate/12_check_phase.ttl b/rocrate_validator/profiles/five-safes-crate/12_check_phase.ttl index ca7ec44f1..fc4d100f5 100644 --- a/rocrate_validator/profiles/five-safes-crate/12_check_phase.ttl +++ b/rocrate_validator/profiles/five-safes-crate/12_check_phase.ttl @@ -13,7 +13,7 @@ # limitations under the License. @prefix ro: <./> . -@prefix ro-crate: . +@prefix ro-crate: . @prefix five-safes-crate: . @prefix rdf: . @prefix schema: . diff --git a/rocrate_validator/profiles/five-safes-crate/13_validation_phase.ttl b/rocrate_validator/profiles/five-safes-crate/13_validation_phase.ttl index f93ed2452..e9d25d46b 100644 --- a/rocrate_validator/profiles/five-safes-crate/13_validation_phase.ttl +++ b/rocrate_validator/profiles/five-safes-crate/13_validation_phase.ttl @@ -13,7 +13,7 @@ # limitations under the License. @prefix ro: <./> . -@prefix ro-crate: . +@prefix ro-crate: . @prefix five-safes-crate: . @prefix rdf: . @prefix schema: . diff --git a/rocrate_validator/profiles/five-safes-crate/14_workflow_retrieval_phase.ttl b/rocrate_validator/profiles/five-safes-crate/14_workflow_retrieval_phase.ttl index 97e7970ef..df7ad33e8 100644 --- a/rocrate_validator/profiles/five-safes-crate/14_workflow_retrieval_phase.ttl +++ b/rocrate_validator/profiles/five-safes-crate/14_workflow_retrieval_phase.ttl @@ -13,7 +13,7 @@ # limitations under the License. @prefix ro: <./> . -@prefix ro-crate: . +@prefix ro-crate: . @prefix five-safes-crate: . @prefix rdf: . @prefix schema: . diff --git a/rocrate_validator/profiles/five-safes-crate/15_metadata_file.py b/rocrate_validator/profiles/five-safes-crate/15_metadata_file.py index b589d332f..f284bfe8a 100644 --- a/rocrate_validator/profiles/five-safes-crate/15_metadata_file.py +++ b/rocrate_validator/profiles/five-safes-crate/15_metadata_file.py @@ -36,20 +36,13 @@ def test_existence(self, context: ValidationContext) -> bool: try: json_dict = context.ro_crate.metadata.as_dict() context_value = json_dict["@context"] - pattern = re.compile( - r"https://w3id\.org/ro/crate/1\.[2-9](-DRAFT)?/context" - ) + pattern = re.compile(r"https://w3id\.org/ro/crate/1\.[2-9](-DRAFT)?/context") passed = True if isinstance(context_value, list): - if not any( - pattern.match(item) - for item in context_value - if isinstance(item, str) - ): - passed = False - else: - if not pattern.match(context_value): + if not any(pattern.match(item) for item in context_value if isinstance(item, str)): passed = False + elif not pattern.match(context_value): + passed = False if not passed: context.result.add_issue( "The RO-Crate metadata file MUST include the RO-Crate context " @@ -58,7 +51,7 @@ def test_existence(self, context: ValidationContext) -> bool: ) return passed - except Exception as e: + except Exception: if logger.isEnabledFor(logging.DEBUG): - logger.exception(e) + logger.exception("Unexpected error during RO-Crate context version check") return True diff --git a/rocrate_validator/profiles/five-safes-crate/15_metadata_file.ttl b/rocrate_validator/profiles/five-safes-crate/15_metadata_file.ttl index 9de856f0e..72f5e020e 100644 --- a/rocrate_validator/profiles/five-safes-crate/15_metadata_file.ttl +++ b/rocrate_validator/profiles/five-safes-crate/15_metadata_file.ttl @@ -12,7 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -@prefix ro-crate: . +@prefix ro-crate: . @prefix five-safes-crate: . @prefix rdf: . @prefix schema: . diff --git a/rocrate_validator/profiles/five-safes-crate/16_publishing_phase.ttl b/rocrate_validator/profiles/five-safes-crate/16_publishing_phase.ttl index 02b5b501f..c56e67b72 100644 --- a/rocrate_validator/profiles/five-safes-crate/16_publishing_phase.ttl +++ b/rocrate_validator/profiles/five-safes-crate/16_publishing_phase.ttl @@ -13,7 +13,7 @@ # limitations under the License. @prefix ro: <./> . -@prefix ro-crate: . +@prefix ro-crate: . @prefix five-safes-crate: . @prefix rdf: . @prefix schema: . diff --git a/rocrate_validator/profiles/five-safes-crate/1_requesting_agent.ttl b/rocrate_validator/profiles/five-safes-crate/1_requesting_agent.ttl index 0e70407f5..812691666 100644 --- a/rocrate_validator/profiles/five-safes-crate/1_requesting_agent.ttl +++ b/rocrate_validator/profiles/five-safes-crate/1_requesting_agent.ttl @@ -13,7 +13,7 @@ # limitations under the License. @prefix ro: <./> . -@prefix ro-crate: . +@prefix ro-crate: . @prefix five-safes-crate: . @prefix rdf: . @prefix schema: . diff --git a/rocrate_validator/profiles/five-safes-crate/1_responsible_project.ttl b/rocrate_validator/profiles/five-safes-crate/1_responsible_project.ttl index 305e7731f..7be332d23 100644 --- a/rocrate_validator/profiles/five-safes-crate/1_responsible_project.ttl +++ b/rocrate_validator/profiles/five-safes-crate/1_responsible_project.ttl @@ -13,7 +13,7 @@ # limitations under the License. @prefix ro: <./> . -@prefix ro-crate: . +@prefix ro-crate: . @prefix five-safes-crate: . @prefix rdf: . @prefix schema: . diff --git a/rocrate_validator/profiles/five-safes-crate/1_root_data_entity.ttl b/rocrate_validator/profiles/five-safes-crate/1_root_data_entity.ttl index fe0516b4f..b5481fd12 100644 --- a/rocrate_validator/profiles/five-safes-crate/1_root_data_entity.ttl +++ b/rocrate_validator/profiles/five-safes-crate/1_root_data_entity.ttl @@ -13,7 +13,7 @@ # limitations under the License. @prefix ro: <./> . -@prefix ro-crate: . +@prefix ro-crate: . @prefix five-safes-crate: . @prefix rdf: . @prefix schema: . diff --git a/rocrate_validator/profiles/five-safes-crate/2_requesting_agent.ttl b/rocrate_validator/profiles/five-safes-crate/2_requesting_agent.ttl index 865c6da2b..49e5ba3f1 100644 --- a/rocrate_validator/profiles/five-safes-crate/2_requesting_agent.ttl +++ b/rocrate_validator/profiles/five-safes-crate/2_requesting_agent.ttl @@ -13,7 +13,7 @@ # limitations under the License. @prefix ro: <./> . -@prefix ro-crate: . +@prefix ro-crate: . @prefix five-safes-crate: . @prefix rdf: . @prefix schema: . diff --git a/rocrate_validator/profiles/five-safes-crate/3_timestamp_format.ttl b/rocrate_validator/profiles/five-safes-crate/3_timestamp_format.ttl index 9f6122220..64055a033 100644 --- a/rocrate_validator/profiles/five-safes-crate/3_timestamp_format.ttl +++ b/rocrate_validator/profiles/five-safes-crate/3_timestamp_format.ttl @@ -13,7 +13,7 @@ # limitations under the License. @prefix ro: <./> . -@prefix ro-crate: . +@prefix ro-crate: . @prefix five-safes-crate: . @prefix rdf: . @prefix schema: . diff --git a/rocrate_validator/profiles/five-safes-crate/4_sign_off.ttl b/rocrate_validator/profiles/five-safes-crate/4_sign_off.ttl index 52abfa619..0c91901e4 100644 --- a/rocrate_validator/profiles/five-safes-crate/4_sign_off.ttl +++ b/rocrate_validator/profiles/five-safes-crate/4_sign_off.ttl @@ -13,7 +13,7 @@ # limitations under the License. @prefix ro: <./> . -@prefix ro-crate: . +@prefix ro-crate: . @prefix five-safes-crate: . @prefix rdf: . @prefix schema: . @@ -190,7 +190,7 @@ five-safes-crate:SignOffPhaseProperties sh:description "Check if the Sign Off phase lists the workflow as an object" ; sh:select """ PREFIX schema: - PREFIX rocrate: + PREFIX rocrate: SELECT $this WHERE { ?root a schema:Dataset ; @@ -209,7 +209,7 @@ five-safes-crate:SignOffPhaseProperties sh:description "Check if the Sign Off phase lists the Responsible Project as an object" ; sh:select """ PREFIX schema: - PREFIX rocrate: + PREFIX rocrate: SELECT $this WHERE { ?root a schema:Dataset ; diff --git a/rocrate_validator/profiles/five-safes-crate/5_profile_conformance.ttl b/rocrate_validator/profiles/five-safes-crate/5_profile_conformance.ttl index e9428e60c..069d390ed 100644 --- a/rocrate_validator/profiles/five-safes-crate/5_profile_conformance.ttl +++ b/rocrate_validator/profiles/five-safes-crate/5_profile_conformance.ttl @@ -13,7 +13,7 @@ # limitations under the License. @prefix ro: <./> . -@prefix ro-crate: . +@prefix ro-crate: . @prefix five-safes-crate: . @prefix rdf: . @prefix schema: . diff --git a/rocrate_validator/profiles/five-safes-crate/6_workflow_reference.ttl b/rocrate_validator/profiles/five-safes-crate/6_workflow_reference.ttl index 250b67da8..222f2bc9b 100644 --- a/rocrate_validator/profiles/five-safes-crate/6_workflow_reference.ttl +++ b/rocrate_validator/profiles/five-safes-crate/6_workflow_reference.ttl @@ -13,7 +13,7 @@ # limitations under the License. @prefix ro: <./> . -@prefix ro-crate: . +@prefix ro-crate: . @prefix five-safes-crate: . @prefix rdf: . @prefix schema: . diff --git a/rocrate_validator/profiles/five-safes-crate/7_requested_workflow_run.ttl b/rocrate_validator/profiles/five-safes-crate/7_requested_workflow_run.ttl index d74acf430..9b66f1769 100644 --- a/rocrate_validator/profiles/five-safes-crate/7_requested_workflow_run.ttl +++ b/rocrate_validator/profiles/five-safes-crate/7_requested_workflow_run.ttl @@ -13,7 +13,7 @@ # limitations under the License. @prefix ro: <./> . -@prefix ro-crate: . +@prefix ro-crate: . @prefix five-safes-crate: . @prefix rdf: . @prefix schema: . diff --git a/rocrate_validator/profiles/five-safes-crate/8_disclosure_phase.ttl b/rocrate_validator/profiles/five-safes-crate/8_disclosure_phase.ttl index 30de9c265..61b785a43 100644 --- a/rocrate_validator/profiles/five-safes-crate/8_disclosure_phase.ttl +++ b/rocrate_validator/profiles/five-safes-crate/8_disclosure_phase.ttl @@ -13,7 +13,7 @@ # limitations under the License. @prefix ro: <./> . -@prefix ro-crate: . +@prefix ro-crate: . @prefix five-safes-crate: . @prefix rdf: . @prefix schema: . diff --git a/rocrate_validator/profiles/five-safes-crate/9_inputs.ttl b/rocrate_validator/profiles/five-safes-crate/9_inputs.ttl index 0a476d4a2..e0e83c940 100644 --- a/rocrate_validator/profiles/five-safes-crate/9_inputs.ttl +++ b/rocrate_validator/profiles/five-safes-crate/9_inputs.ttl @@ -13,7 +13,7 @@ # limitations under the License. @prefix ro: <./> . -@prefix ro-crate: . +@prefix ro-crate: . @prefix five-safes-crate: . @prefix rdf: . @prefix schema: . diff --git a/rocrate_validator/profiles/five-safes-crate/ontology.ttl b/rocrate_validator/profiles/five-safes-crate/ontology.ttl index a7f291fac..d37dfd45e 100644 --- a/rocrate_validator/profiles/five-safes-crate/ontology.ttl +++ b/rocrate_validator/profiles/five-safes-crate/ontology.ttl @@ -21,7 +21,7 @@ @prefix schema: . @prefix rocrate: . @prefix bioschemas: . -@prefix ro-crate: . +@prefix ro-crate: . @prefix isa-ro-crate: . rdf:type owl:Ontology ; diff --git a/rocrate_validator/profiles/five-safes-crate/profile.ttl b/rocrate_validator/profiles/five-safes-crate/profile.ttl index f144e01be..28abe62c0 100644 --- a/rocrate_validator/profiles/five-safes-crate/profile.ttl +++ b/rocrate_validator/profiles/five-safes-crate/profile.ttl @@ -34,7 +34,7 @@ # prof:isProfileOf ; # This profile is a transitive profile of the RO-Crate Metadata Specification - prof:isTransitiveProfileOf ; + prof:isTransitiveProfileOf ; # TODO: resolve failures when these profiles are applied # , # ; diff --git a/tests/data/crates/valid/five-safes-crate-result/ro-crate-metadata.json b/tests/data/crates/valid/five-safes-crate-result/ro-crate-metadata.json index 324533139..2fa6838d2 100644 --- a/tests/data/crates/valid/five-safes-crate-result/ro-crate-metadata.json +++ b/tests/data/crates/valid/five-safes-crate-result/ro-crate-metadata.json @@ -393,6 +393,8 @@ "@id": "https://tre72.example.com/#crate-validator", "@type": "SoftwareApplication", "name": "RO-Crate validator at TRE72", + "url": "https://tre72.example.com/#crate-validator", + "version": "1.0", "provider": { "@id": "https://tre72.example.com/" } diff --git a/tests/integration/profiles/five-safes-crate/test_5src_10_outputs.py b/tests/integration/profiles/five-safes-crate/test_5src_10_outputs.py index 1cbdbe6d0..15dcc2449 100644 --- a/tests/integration/profiles/five-safes-crate/test_5src_10_outputs.py +++ b/tests/integration/profiles/five-safes-crate/test_5src_10_outputs.py @@ -17,7 +17,7 @@ from rocrate_validator.models import Severity from tests.ro_crates import ValidROC -from tests.shared import do_entity_test, SPARQL_PREFIXES +from tests.shared import SPARQL_PREFIXES, do_entity_test # set up logging logger = logging.getLogger(__name__) @@ -87,9 +87,7 @@ def test_result_output_does_not_have_allowed_type(): requirement_severity=Severity.RECOMMENDED, expected_validation_result=False, expected_triggered_requirements=["Output"], - expected_triggered_issues=[ - "Result SHOULD have a `@type` among an allowed set of values." - ], + expected_triggered_issues=["Result SHOULD have a `@type` among an allowed set of values."], profile_identifier="five-safes-crate", rocrate_entity_mod_sparql=sparql, ) diff --git a/tests/integration/profiles/five-safes-crate/test_5src_11_workflow_execution.py b/tests/integration/profiles/five-safes-crate/test_5src_11_workflow_execution.py index a271978a8..9f54354d9 100644 --- a/tests/integration/profiles/five-safes-crate/test_5src_11_workflow_execution.py +++ b/tests/integration/profiles/five-safes-crate/test_5src_11_workflow_execution.py @@ -17,7 +17,7 @@ from rocrate_validator.models import Severity from tests.ro_crates import ValidROC -from tests.shared import do_entity_test, SPARQL_PREFIXES +from tests.shared import SPARQL_PREFIXES, do_entity_test # set up logging logger = logging.getLogger(__name__) @@ -267,9 +267,7 @@ def test_5src_workflow_object_has_no_end_time_if_ended(): requirement_severity=Severity.RECOMMENDED, expected_validation_result=False, expected_triggered_requirements=["WorkflowExecution"], - expected_triggered_issues=[ - "The workflow execution object SHOULD have an endTime property if it has ended." - ], + expected_triggered_issues=["The workflow execution object SHOULD have an endTime property if it has ended."], profile_identifier="five-safes-crate", rocrate_entity_mod_sparql=sparql, ) diff --git a/tests/integration/profiles/five-safes-crate/test_5src_13_validation_phase.py b/tests/integration/profiles/five-safes-crate/test_5src_13_validation_phase.py index be6f44906..c19e54663 100644 --- a/tests/integration/profiles/five-safes-crate/test_5src_13_validation_phase.py +++ b/tests/integration/profiles/five-safes-crate/test_5src_13_validation_phase.py @@ -17,7 +17,7 @@ from rocrate_validator.models import Severity from tests.ro_crates import ValidROC -from tests.shared import do_entity_test, SPARQL_PREFIXES +from tests.shared import SPARQL_PREFIXES, do_entity_test # set up logging logger = logging.getLogger(__name__) @@ -75,9 +75,7 @@ def test_5src_validation_check_name_not_a_string(): requirement_severity=Severity.REQUIRED, expected_validation_result=False, expected_triggered_requirements=["ValidationCheck"], - expected_triggered_issues=[ - "ValidationCheck MUST have a human readable name string." - ], + expected_triggered_issues=["ValidationCheck MUST have a human readable name string."], profile_identifier="five-safes-crate", rocrate_entity_mod_sparql=sparql, ) @@ -200,9 +198,7 @@ def test_5src_root_data_entity_does_not_mention_validation_check_entity(): requirement_severity=Severity.RECOMMENDED, expected_validation_result=False, expected_triggered_requirements=["RootDataEntity"], - expected_triggered_issues=[ - "RootDataEntity SHOULD mention a ValidationCheck object." - ], + expected_triggered_issues=["RootDataEntity SHOULD mention a ValidationCheck object."], profile_identifier="five-safes-crate", rocrate_entity_mod_sparql=sparql, ) @@ -229,9 +225,7 @@ def test_5src_validation_check_object_does_not_point_to_root_data_entity(): requirement_severity=Severity.RECOMMENDED, expected_validation_result=False, expected_triggered_requirements=["ValidationCheck"], - expected_triggered_issues=[ - "`ValidationCheck` --> `object` SHOULD point to the root of the RO-Crate" - ], + expected_triggered_issues=["`ValidationCheck` --> `object` SHOULD point to the root of the RO-Crate"], profile_identifier="five-safes-crate", rocrate_entity_mod_sparql=sparql, ) @@ -283,9 +277,7 @@ def test_5src_Validation_check_does_not_have_action_status_property(): requirement_severity=Severity.RECOMMENDED, expected_validation_result=False, expected_triggered_requirements=["ValidationCheck"], - expected_triggered_issues=[ - "ValidationCheck SHOULD have actionStatus property." - ], + expected_triggered_issues=["ValidationCheck SHOULD have actionStatus property."], profile_identifier="five-safes-crate", rocrate_entity_mod_sparql=sparql, ) diff --git a/tests/integration/profiles/five-safes-crate/test_5src_14_workflow_retrieval_phase.py b/tests/integration/profiles/five-safes-crate/test_5src_14_workflow_retrieval_phase.py index 52228408e..c7d92d0cd 100644 --- a/tests/integration/profiles/five-safes-crate/test_5src_14_workflow_retrieval_phase.py +++ b/tests/integration/profiles/five-safes-crate/test_5src_14_workflow_retrieval_phase.py @@ -17,7 +17,7 @@ from rocrate_validator.models import Severity from tests.ro_crates import ValidROC -from tests.shared import do_entity_test, SPARQL_PREFIXES +from tests.shared import SPARQL_PREFIXES, do_entity_test # set up logging logger = logging.getLogger(__name__) @@ -45,9 +45,7 @@ def test_5src_download_action_does_not_have_name(): requirement_severity=Severity.REQUIRED, expected_validation_result=False, expected_triggered_requirements=["DownloadAction"], - expected_triggered_issues=[ - "DownloadAction MUST have a human readable name string." - ], + expected_triggered_issues=["DownloadAction MUST have a human readable name string."], profile_identifier="five-safes-crate", rocrate_entity_mod_sparql=sparql, ) @@ -74,9 +72,7 @@ def test_5src_download_action_name_not_a_string(): requirement_severity=Severity.REQUIRED, expected_validation_result=False, expected_triggered_requirements=["DownloadAction"], - expected_triggered_issues=[ - "DownloadAction MUST have a human readable name string." - ], + expected_triggered_issues=["DownloadAction MUST have a human readable name string."], profile_identifier="five-safes-crate", rocrate_entity_mod_sparql=sparql, ) @@ -206,10 +202,7 @@ def test_5src_downloaded_workflow_distribution_is_not_the_same_as_download_actio expected_validation_result=False, expected_triggered_requirements=["Downloaded Workflow"], expected_triggered_issues=[ - ( - "DownloadedWorkflow --> `distribution` MUST reference " - "the same entity as `DownloadAction` --> `object`." - ) + ("DownloadedWorkflow --> `distribution` MUST reference the same entity as `DownloadAction` --> `object`.") ], profile_identifier="five-safes-crate", rocrate_entity_mod_sparql=sparql, @@ -295,9 +288,7 @@ def test_5src_root_data_entity_does_not_mention_download_action_entity(): requirement_severity=Severity.RECOMMENDED, expected_validation_result=False, expected_triggered_requirements=["RootDataEntity"], - expected_triggered_issues=[ - "RootDataEntity SHOULD mention DownloadAction if this exists." - ], + expected_triggered_issues=["RootDataEntity SHOULD mention DownloadAction if this exists."], profile_identifier="five-safes-crate", rocrate_entity_mod_sparql=sparql, ) @@ -352,9 +343,7 @@ def test_5src_download_action_does_not_have_action_status_property(): requirement_severity=Severity.RECOMMENDED, expected_validation_result=False, expected_triggered_requirements=["DownloadAction"], - expected_triggered_issues=[ - "`DownloadAction` SHOULD have `actionStatus` property." - ], + expected_triggered_issues=["`DownloadAction` SHOULD have `actionStatus` property."], profile_identifier="five-safes-crate", rocrate_entity_mod_sparql=sparql, ) diff --git a/tests/integration/profiles/five-safes-crate/test_5src_15_metadata_file.py b/tests/integration/profiles/five-safes-crate/test_5src_15_metadata_file.py index e94a76fa9..a166ed4aa 100644 --- a/tests/integration/profiles/five-safes-crate/test_5src_15_metadata_file.py +++ b/tests/integration/profiles/five-safes-crate/test_5src_15_metadata_file.py @@ -16,8 +16,8 @@ import logging from rocrate_validator.models import Severity -from tests.ro_crates import ValidROC, Invalid5sROC -from tests.shared import do_entity_test, SPARQL_PREFIXES +from tests.ro_crates import Invalid5sROC, ValidROC +from tests.shared import SPARQL_PREFIXES, do_entity_test # set up logging logger = logging.getLogger(__name__) @@ -47,9 +47,7 @@ def test_5src_conforms_to_old_version(): rocrate_path=ValidROC().five_safes_crate_request, requirement_severity=Severity.REQUIRED, expected_validation_result=False, - expected_triggered_requirements=[ - "RO-Crate conforms to 1.2 or later minor version" - ], + expected_triggered_requirements=["RO-Crate conforms to 1.2 or later minor version"], expected_triggered_issues=[ "The RO-Crate metadata file descriptor MUST have a `conformsTo` property with " "RO-Crate specification version 1.2 or later minor version" diff --git a/tests/integration/profiles/five-safes-crate/test_5src_16_publishing_phase.py b/tests/integration/profiles/five-safes-crate/test_5src_16_publishing_phase.py index 8149d1b24..485aeb026 100644 --- a/tests/integration/profiles/five-safes-crate/test_5src_16_publishing_phase.py +++ b/tests/integration/profiles/five-safes-crate/test_5src_16_publishing_phase.py @@ -17,7 +17,7 @@ from rocrate_validator.models import Severity from tests.ro_crates import ValidROC -from tests.shared import do_entity_test, SPARQL_PREFIXES +from tests.shared import SPARQL_PREFIXES, do_entity_test # set up logging logger = logging.getLogger(__name__) @@ -44,12 +44,9 @@ def test_5src_assess_action_not_referenced_from_rde(): rocrate_path=ValidROC().five_safes_crate_result, requirement_severity=Severity.REQUIRED, expected_validation_result=False, - expected_triggered_requirements=[ - "All AssessActions are mentioned from Root Data Entity" - ], + expected_triggered_requirements=["All AssessActions are mentioned from Root Data Entity"], expected_triggered_issues=[ - "All AssessAction entities in the crate MUST be referenced from " - "the Root Dataset via `mentions`." + "All AssessAction entities in the crate MUST be referenced from the Root Dataset via `mentions`." ], profile_identifier="five-safes-crate", rocrate_entity_mod_sparql=sparql, diff --git a/tests/integration/profiles/five-safes-crate/test_5src_1_requesting_agent.py b/tests/integration/profiles/five-safes-crate/test_5src_1_requesting_agent.py index 1ab9b4b37..84c1372a7 100644 --- a/tests/integration/profiles/five-safes-crate/test_5src_1_requesting_agent.py +++ b/tests/integration/profiles/five-safes-crate/test_5src_1_requesting_agent.py @@ -17,7 +17,7 @@ from rocrate_validator.models import Severity from tests.ro_crates import ValidROC -from tests.shared import do_entity_test, SPARQL_PREFIXES +from tests.shared import SPARQL_PREFIXES, do_entity_test # set up logging logger = logging.getLogger(__name__) @@ -54,9 +54,7 @@ def test_5src_agent_memberOf_not_project(): requirement_severity=Severity.REQUIRED, expected_validation_result=False, expected_triggered_requirements=["Requesting Agent"], - expected_triggered_issues=[ - "The 'memberOf' property of an agent MUST be of type Project." - ], + expected_triggered_issues=["The 'memberOf' property of an agent MUST be of type Project."], profile_identifier="five-safes-crate", rocrate_entity_mod_sparql=sparql, ) @@ -131,9 +129,7 @@ def test_5src_agent_memberOf_missing_warning(): requirement_severity=Severity.RECOMMENDED, expected_validation_result=False, # or True if warnings are not treated as failures expected_triggered_requirements=["Requesting Agent"], - expected_triggered_issues=[ - "The Requesting Agent SHOULD have a `memberOf` property." - ], + expected_triggered_issues=["The Requesting Agent SHOULD have a `memberOf` property."], profile_identifier="five-safes-crate", rocrate_entity_mod_sparql=sparql, ) diff --git a/tests/integration/profiles/five-safes-crate/test_5src_1_responsible_project.py b/tests/integration/profiles/five-safes-crate/test_5src_1_responsible_project.py index 1f5c9664b..96bda9e82 100644 --- a/tests/integration/profiles/five-safes-crate/test_5src_1_responsible_project.py +++ b/tests/integration/profiles/five-safes-crate/test_5src_1_responsible_project.py @@ -17,7 +17,7 @@ from rocrate_validator.models import Severity from tests.ro_crates import ValidROC -from tests.shared import do_entity_test, SPARQL_PREFIXES +from tests.shared import SPARQL_PREFIXES, do_entity_test # set up logging logger = logging.getLogger(__name__) @@ -56,9 +56,7 @@ def test_5src_responsible_project_funding_not_grant(): requirement_severity=Severity.REQUIRED, expected_validation_result=False, expected_triggered_requirements=["Responsible Project"], - expected_triggered_issues=[ - "The property 'funding' of the Responsible Project MUST be of type Grant." - ], + expected_triggered_issues=["The property 'funding' of the Responsible Project MUST be of type Grant."], profile_identifier="five-safes-crate", rocrate_entity_mod_sparql=sparql, ) @@ -136,9 +134,7 @@ def test_5src_responsible_project_member_and_agent_affiliation_no_intersection() rocrate_path=ValidROC().five_safes_crate_request, requirement_severity=Severity.RECOMMENDED, expected_validation_result=False, - expected_triggered_requirements=[ - "Organizations (members of Responsible Project)" - ], + expected_triggered_requirements=["Organizations (members of Responsible Project)"], expected_triggered_issues=[ ( "At least one of the organisations that are members of the responsible project SHOULD " @@ -178,9 +174,7 @@ def test_5src_responsible_project_missing_funding_property(): requirement_severity=Severity.OPTIONAL, expected_validation_result=False, expected_triggered_requirements=["Responsible Project"], - expected_triggered_issues=[ - "The Responsible Project does not have the property `funding`." - ], + expected_triggered_issues=["The Responsible Project does not have the property `funding`."], profile_identifier="five-safes-crate", rocrate_entity_mod_sparql=sparql, ) @@ -211,9 +205,7 @@ def test_5src_responsible_project_missing_member_property(): requirement_severity=Severity.OPTIONAL, expected_validation_result=False, expected_triggered_requirements=["Responsible Project"], - expected_triggered_issues=[ - "The Responsible Project does not have the property `member`." - ], + expected_triggered_issues=["The Responsible Project does not have the property `member`."], profile_identifier="five-safes-crate", rocrate_entity_mod_sparql=sparql, ) diff --git a/tests/integration/profiles/five-safes-crate/test_5src_1_root_data_entity_metadata.py b/tests/integration/profiles/five-safes-crate/test_5src_1_root_data_entity_metadata.py index 23c51832d..19e3f21fe 100644 --- a/tests/integration/profiles/five-safes-crate/test_5src_1_root_data_entity_metadata.py +++ b/tests/integration/profiles/five-safes-crate/test_5src_1_root_data_entity_metadata.py @@ -17,7 +17,7 @@ from rocrate_validator.models import Severity from tests.ro_crates import ValidROC -from tests.shared import do_entity_test, SPARQL_PREFIXES +from tests.shared import SPARQL_PREFIXES, do_entity_test # set up logging logger = logging.getLogger(__name__) @@ -47,9 +47,7 @@ def test_5src_root_data_entity_without_source_organization(): requirement_severity=Severity.REQUIRED, expected_validation_result=False, expected_triggered_requirements=["RootDataEntity"], - expected_triggered_issues=[ - """The Root Data Entity MUST have a `sourceOrganization` property.""" - ], + expected_triggered_issues=["""The Root Data Entity MUST have a `sourceOrganization` property."""], profile_identifier="five-safes-crate", rocrate_entity_mod_sparql=sparql, ) diff --git a/tests/integration/profiles/five-safes-crate/test_5src_2_requesting_agent.py b/tests/integration/profiles/five-safes-crate/test_5src_2_requesting_agent.py index 41a4279d1..7f496cdac 100644 --- a/tests/integration/profiles/five-safes-crate/test_5src_2_requesting_agent.py +++ b/tests/integration/profiles/five-safes-crate/test_5src_2_requesting_agent.py @@ -17,7 +17,7 @@ from rocrate_validator.models import Severity from tests.ro_crates import ValidROC -from tests.shared import do_entity_test, SPARQL_PREFIXES +from tests.shared import SPARQL_PREFIXES, do_entity_test # set up logging logger = logging.getLogger(__name__) @@ -50,9 +50,7 @@ def test_createaction_does_not_have_agent(): requirement_severity=Severity.REQUIRED, expected_validation_result=False, expected_triggered_requirements=["CreateAction"], - expected_triggered_issues=[ - "CreateAction MUST have at least one agent that is a contextual entity." - ], + expected_triggered_issues=["CreateAction MUST have at least one agent that is a contextual entity."], profile_identifier="five-safes-crate", rocrate_entity_mod_sparql=sparql, ) diff --git a/tests/integration/profiles/five-safes-crate/test_5src_4_signoff_phase.py b/tests/integration/profiles/five-safes-crate/test_5src_4_signoff_phase.py index a98c850bd..79d08229f 100644 --- a/tests/integration/profiles/five-safes-crate/test_5src_4_signoff_phase.py +++ b/tests/integration/profiles/five-safes-crate/test_5src_4_signoff_phase.py @@ -17,7 +17,7 @@ from rocrate_validator.models import Severity from tests.ro_crates import ValidROC -from tests.shared import do_entity_test, SPARQL_PREFIXES +from tests.shared import SPARQL_PREFIXES, do_entity_test # set up logging logger = logging.getLogger(__name__) @@ -48,9 +48,7 @@ def test_5src_no_signoff_phase(): requirement_severity=Severity.RECOMMENDED, expected_validation_result=False, expected_triggered_requirements=["SignOffPhase"], - expected_triggered_issues=[ - "There SHOULD be a Sign-Off Phase in the Final RO-Crate" - ], + expected_triggered_issues=["There SHOULD be a Sign-Off Phase in the Final RO-Crate"], profile_identifier="five-safes-crate", rocrate_entity_mod_sparql=sparql, ) @@ -79,9 +77,7 @@ def test_5src_signoff_phase_no_name(): requirement_severity=Severity.REQUIRED, expected_validation_result=False, expected_triggered_requirements=["SignOff"], - expected_triggered_issues=[ - "Sign Off phase MUST have a human-readable name string." - ], + expected_triggered_issues=["Sign Off phase MUST have a human-readable name string."], profile_identifier="five-safes-crate", rocrate_entity_mod_sparql=sparql, ) @@ -147,7 +143,7 @@ def test_5src_signoff_phase_wrong_action_status(): expected_triggered_requirements=["SignOffStatus"], expected_triggered_issues=[ "The value of actionStatus MUST be one of the allowed values:" - + " PotentialActionStatus; ActiveActionStatus; CompletedActionStatus; FailedActionStatus." + " PotentialActionStatus; ActiveActionStatus; CompletedActionStatus; FailedActionStatus." ], profile_identifier="five-safes-crate", rocrate_entity_mod_sparql=sparql, @@ -175,9 +171,7 @@ def test_5src_signoff_phase_not_mentioned(): requirement_severity=Severity.RECOMMENDED, expected_validation_result=False, expected_triggered_requirements=["SignOffPhase"], - expected_triggered_issues=[ - "The Root Data Entity SHOULD mention a Sign-Off Phase Object" - ], + expected_triggered_issues=["The Root Data Entity SHOULD mention a Sign-Off Phase Object"], profile_identifier="five-safes-crate", rocrate_entity_mod_sparql=sparql, ) @@ -206,9 +200,7 @@ def test_5src_signoff_phase_no_endtime(): requirement_severity=Severity.RECOMMENDED, expected_validation_result=False, expected_triggered_requirements=["SignOffPhaseEndTime"], - expected_triggered_issues=[ - "Sign Off object SHOULD have endTime property if action completed or failed." - ], + expected_triggered_issues=["Sign Off object SHOULD have endTime property if action completed or failed."], profile_identifier="five-safes-crate", rocrate_entity_mod_sparql=sparql, ) @@ -402,9 +394,7 @@ def test_5src_signoff_phase_no_instrument(): requirement_severity=Severity.RECOMMENDED, expected_validation_result=False, expected_triggered_requirements=["SignOffPhaseProperties"], - expected_triggered_issues=[ - "The Sign-Off Phase SHOULD have an TRE policy (instrument) with type CreativeWork" - ], + expected_triggered_issues=["The Sign-Off Phase SHOULD have an TRE policy (instrument) with type CreativeWork"], profile_identifier="five-safes-crate", rocrate_entity_mod_sparql=sparql, ) @@ -436,9 +426,7 @@ def test_5src_signoff_phase_instrument_not_iri(): requirement_severity=Severity.RECOMMENDED, expected_validation_result=False, expected_triggered_requirements=["SignOffPhaseProperties"], - expected_triggered_issues=[ - "The Sign-Off Phase SHOULD have an TRE policy (instrument) with type CreativeWork" - ], + expected_triggered_issues=["The Sign-Off Phase SHOULD have an TRE policy (instrument) with type CreativeWork"], profile_identifier="five-safes-crate", rocrate_entity_mod_sparql=sparql, ) @@ -468,9 +456,7 @@ def test_5src_signoff_phase_instrument_no_type(): requirement_severity=Severity.RECOMMENDED, expected_validation_result=False, expected_triggered_requirements=["SignOffPhaseProperties"], - expected_triggered_issues=[ - "The Sign-Off Phase SHOULD have an TRE policy (instrument) with type CreativeWork" - ], + expected_triggered_issues=["The Sign-Off Phase SHOULD have an TRE policy (instrument) with type CreativeWork"], profile_identifier="five-safes-crate", rocrate_entity_mod_sparql=sparql, ) @@ -534,9 +520,7 @@ def test_5src_signoff_phase_object_notworkflow(): requirement_severity=Severity.RECOMMENDED, expected_validation_result=False, expected_triggered_requirements=["SignOffPhaseProperties"], - expected_triggered_issues=[ - "The Sign-Off Phase SHOULD list the workflow (mainEntity) as an object" - ], + expected_triggered_issues=["The Sign-Off Phase SHOULD list the workflow (mainEntity) as an object"], profile_identifier="five-safes-crate", rocrate_entity_mod_sparql=sparql, ) diff --git a/tests/integration/profiles/five-safes-crate/test_5src_5_profile_conformance.py b/tests/integration/profiles/five-safes-crate/test_5src_5_profile_conformance.py index 313e794e4..8012a37b4 100644 --- a/tests/integration/profiles/five-safes-crate/test_5src_5_profile_conformance.py +++ b/tests/integration/profiles/five-safes-crate/test_5src_5_profile_conformance.py @@ -17,7 +17,7 @@ from rocrate_validator.models import Severity from tests.ro_crates import ValidROC -from tests.shared import do_entity_test, SPARQL_PREFIXES +from tests.shared import SPARQL_PREFIXES, do_entity_test # set up logging logger = logging.getLogger(__name__) @@ -52,9 +52,7 @@ def test_5src_root_data_entity_missing_conformsto_property(): requirement_severity=Severity.RECOMMENDED, expected_validation_result=False, expected_triggered_requirements=["RootDataEntity"], - expected_triggered_issues=[ - "Root Dataset SHOULD include `conformsTo` https://w3id.org/5s-crate/0.4" - ], + expected_triggered_issues=["Root Dataset SHOULD include `conformsTo` https://w3id.org/5s-crate/0.4"], profile_identifier="five-safes-crate", rocrate_entity_mod_sparql=sparql, ) @@ -86,9 +84,7 @@ def test_5src_root_data_entity_conforms_to_wrong_profile(): requirement_severity=Severity.RECOMMENDED, expected_validation_result=False, expected_triggered_requirements=["RootDataEntity"], - expected_triggered_issues=[ - "Root Dataset SHOULD include `conformsTo` https://w3id.org/5s-crate/0.4" - ], + expected_triggered_issues=["Root Dataset SHOULD include `conformsTo` https://w3id.org/5s-crate/0.4"], profile_identifier="five-safes-crate", rocrate_entity_mod_sparql=sparql, ) @@ -118,9 +114,7 @@ def test_5src_root_data_entity_has_publisher_but_not_date_published(): requirement_severity=Severity.RECOMMENDED, expected_validation_result=False, expected_triggered_requirements=["datePublished present on published crates"], - expected_triggered_issues=[ - "A crate SHOULD have a publishedDate if and only if it has a publisher." - ], + expected_triggered_issues=["A crate SHOULD have a publishedDate if and only if it has a publisher."], profile_identifier="five-safes-crate", rocrate_entity_mod_sparql=sparql, ) @@ -150,9 +144,7 @@ def test_5src_root_data_entity_has_date_published_but_not_publisher(): requirement_severity=Severity.RECOMMENDED, expected_validation_result=False, expected_triggered_requirements=["datePublished present on published crates"], - expected_triggered_issues=[ - "A crate SHOULD have a publishedDate if and only if it has a publisher." - ], + expected_triggered_issues=["A crate SHOULD have a publishedDate if and only if it has a publisher."], profile_identifier="five-safes-crate", rocrate_entity_mod_sparql=sparql, ) @@ -182,9 +174,7 @@ def test_5src_root_data_entity_has_publisher_but_not_license(): requirement_severity=Severity.RECOMMENDED, expected_validation_result=False, expected_triggered_requirements=["License present on published crates"], - expected_triggered_issues=[ - "Profile Conformance: Published crates SHOULD include a license." - ], + expected_triggered_issues=["Profile Conformance: Published crates SHOULD include a license."], profile_identifier="five-safes-crate", rocrate_entity_mod_sparql=sparql, ) diff --git a/tests/integration/profiles/five-safes-crate/test_5src_6_workflow_reference.py b/tests/integration/profiles/five-safes-crate/test_5src_6_workflow_reference.py index 1271adffd..2aacf26e3 100644 --- a/tests/integration/profiles/five-safes-crate/test_5src_6_workflow_reference.py +++ b/tests/integration/profiles/five-safes-crate/test_5src_6_workflow_reference.py @@ -17,7 +17,7 @@ from rocrate_validator.models import Severity from tests.ro_crates import ValidROC -from tests.shared import do_entity_test, SPARQL_PREFIXES +from tests.shared import SPARQL_PREFIXES, do_entity_test # set up logging logger = logging.getLogger(__name__) @@ -49,9 +49,7 @@ def test_5src_root_data_entity_two_main_entities(): requirement_severity=Severity.REQUIRED, expected_validation_result=False, expected_triggered_requirements=["RootDataEntity"], - expected_triggered_issues=[ - "The RootDataEntity MUST have exactly one mainEntity property that is an IRI." - ], + expected_triggered_issues=["The RootDataEntity MUST have exactly one mainEntity property that is an IRI."], profile_identifier="five-safes-crate", rocrate_entity_mod_sparql=sparql, ) @@ -78,9 +76,7 @@ def test_5src_root_data_entity_no_main_entity(): requirement_severity=Severity.REQUIRED, expected_validation_result=False, expected_triggered_requirements=["RootDataEntity"], - expected_triggered_issues=[ - "The RootDataEntity MUST have exactly one mainEntity property that is an IRI." - ], + expected_triggered_issues=["The RootDataEntity MUST have exactly one mainEntity property that is an IRI."], profile_identifier="five-safes-crate", rocrate_entity_mod_sparql=sparql, ) @@ -113,9 +109,7 @@ def test_5src_root_data_entity_main_entity_not_dataset_iri(): requirement_severity=Severity.REQUIRED, expected_validation_result=False, expected_triggered_requirements=["RootDataEntity"], - expected_triggered_issues=[ - "The mainEntity pointed to by the RootDataEntity MUST be of type Dataset" - ], + expected_triggered_issues=["The mainEntity pointed to by the RootDataEntity MUST be of type Dataset"], profile_identifier="five-safes-crate", rocrate_entity_mod_sparql=sparql, ) @@ -145,9 +139,7 @@ def test_5src_main_entity_conformsTo_absent(): requirement_severity=Severity.REQUIRED, expected_validation_result=False, expected_triggered_requirements=["mainEntity"], - expected_triggered_issues=[ - "mainEntity MUST have one and only one `conformsTo` property." - ], + expected_triggered_issues=["mainEntity MUST have one and only one `conformsTo` property."], profile_identifier="five-safes-crate", rocrate_entity_mod_sparql=sparql, ) @@ -178,9 +170,7 @@ def test_5src_main_entity_has_two_conformsto(): requirement_severity=Severity.REQUIRED, expected_validation_result=False, expected_triggered_requirements=["mainEntity"], - expected_triggered_issues=[ - "mainEntity MUST have one and only one `conformsTo` property." - ], + expected_triggered_issues=["mainEntity MUST have one and only one `conformsTo` property."], profile_identifier="five-safes-crate", rocrate_entity_mod_sparql=sparql, ) @@ -214,9 +204,7 @@ def test_5src_main_entity_conformsTo_invalid(): requirement_severity=Severity.REQUIRED, expected_validation_result=False, expected_triggered_requirements=["mainEntity"], - expected_triggered_issues=[ - "conformsTo IRI must start with https://w3id.org/workflowhub/workflow-ro-crate" - ], + expected_triggered_issues=["conformsTo IRI must start with https://w3id.org/workflowhub/workflow-ro-crate"], profile_identifier="five-safes-crate", rocrate_entity_mod_sparql=sparql, ) diff --git a/tests/integration/profiles/five-safes-crate/test_5src_7_requesting_workflow_run.py b/tests/integration/profiles/five-safes-crate/test_5src_7_requesting_workflow_run.py index b58147651..c2a82ba3e 100644 --- a/tests/integration/profiles/five-safes-crate/test_5src_7_requesting_workflow_run.py +++ b/tests/integration/profiles/five-safes-crate/test_5src_7_requesting_workflow_run.py @@ -17,7 +17,7 @@ from rocrate_validator.models import Severity from tests.ro_crates import ValidROC -from tests.shared import do_entity_test, SPARQL_PREFIXES +from tests.shared import SPARQL_PREFIXES, do_entity_test # set up logging logger = logging.getLogger(__name__) @@ -159,7 +159,7 @@ def test_createaction_object_does_not_reference_existing_entities(): expected_triggered_requirements=["WorkflowRunAction"], expected_triggered_issues=[ "In the `CreateAction` entity corresponding to the workflow run," - + " each `object` MUST reference an existing entity." + " each `object` MUST reference an existing entity." ], profile_identifier="five-safes-crate", rocrate_entity_mod_sparql=sparql, diff --git a/tests/integration/profiles/five-safes-crate/test_5src_8_disclosure_phase.py b/tests/integration/profiles/five-safes-crate/test_5src_8_disclosure_phase.py index b50710cc8..8113a5111 100644 --- a/tests/integration/profiles/five-safes-crate/test_5src_8_disclosure_phase.py +++ b/tests/integration/profiles/five-safes-crate/test_5src_8_disclosure_phase.py @@ -17,7 +17,7 @@ from rocrate_validator.models import Severity from tests.ro_crates import ValidROC -from tests.shared import do_entity_test, SPARQL_PREFIXES +from tests.shared import SPARQL_PREFIXES, do_entity_test # set up logging logger = logging.getLogger(__name__) @@ -46,9 +46,7 @@ def test_5src_disclosure_object_with_no_name(): requirement_severity=Severity.REQUIRED, expected_validation_result=False, expected_triggered_requirements=["DisclosureCheck"], - expected_triggered_issues=[ - "`DisclosureCheck` MUST have a name string of at least 10 characters." - ], + expected_triggered_issues=["`DisclosureCheck` MUST have a name string of at least 10 characters."], profile_identifier="five-safes-crate", rocrate_entity_mod_sparql=sparql, ) @@ -77,9 +75,7 @@ def test_5src_disclosure_object_with_name_not_string(): requirement_severity=Severity.REQUIRED, expected_validation_result=False, expected_triggered_requirements=["DisclosureCheck"], - expected_triggered_issues=[ - "`DisclosureCheck` MUST have a name string of at least 10 characters." - ], + expected_triggered_issues=["`DisclosureCheck` MUST have a name string of at least 10 characters."], profile_identifier="five-safes-crate", rocrate_entity_mod_sparql=sparql, ) @@ -108,9 +104,7 @@ def test_5src_disclosure_object_with_not_long_enough_name(): requirement_severity=Severity.REQUIRED, expected_validation_result=False, expected_triggered_requirements=["DisclosureCheck"], - expected_triggered_issues=[ - "`DisclosureCheck` MUST have a name string of at least 10 characters." - ], + expected_triggered_issues=["`DisclosureCheck` MUST have a name string of at least 10 characters."], profile_identifier="five-safes-crate", rocrate_entity_mod_sparql=sparql, ) @@ -264,9 +258,7 @@ def test_5src_disclosure_object_not_mentioned_by_root_data_entity(): requirement_severity=Severity.RECOMMENDED, expected_validation_result=False, expected_triggered_requirements=["RootDataEntity"], - expected_triggered_issues=[ - "`RootDataEntity` SHOULD mention a disclosure object." - ], + expected_triggered_issues=["`RootDataEntity` SHOULD mention a disclosure object."], profile_identifier="five-safes-crate", rocrate_entity_mod_sparql=sparql, ) @@ -291,9 +283,7 @@ def test_5src_disclosure_object_with_no_action_status(): requirement_severity=Severity.RECOMMENDED, expected_validation_result=False, expected_triggered_requirements=["DisclosureCheck"], - expected_triggered_issues=[ - "The `DisclosureCheck` SHOULD have `actionStatus` property." - ], + expected_triggered_issues=["The `DisclosureCheck` SHOULD have `actionStatus` property."], profile_identifier="five-safes-crate", rocrate_entity_mod_sparql=sparql, ) diff --git a/tests/integration/profiles/five-safes-crate/test_5src_9_inputs.py b/tests/integration/profiles/five-safes-crate/test_5src_9_inputs.py index e6517098d..eb8efa7ef 100644 --- a/tests/integration/profiles/five-safes-crate/test_5src_9_inputs.py +++ b/tests/integration/profiles/five-safes-crate/test_5src_9_inputs.py @@ -17,7 +17,7 @@ from rocrate_validator.models import Severity from tests.ro_crates import ValidROC -from tests.shared import do_entity_test, SPARQL_PREFIXES +from tests.shared import SPARQL_PREFIXES, do_entity_test # set up logging logger = logging.getLogger(__name__) @@ -56,9 +56,7 @@ def test_input_does_not_reference_formalparameter(): requirement_severity=Severity.RECOMMENDED, expected_validation_result=False, expected_triggered_requirements=["Input"], - expected_triggered_issues=[ - "Input SHOULD reference a FormalParameter using exampleOfWork" - ], + expected_triggered_issues=["Input SHOULD reference a FormalParameter using exampleOfWork"], profile_identifier="five-safes-crate", rocrate_entity_mod_sparql=sparql, ) diff --git a/tests/integration/profiles/five-safes-crate/test_valid_5src.py b/tests/integration/profiles/five-safes-crate/test_valid_5src.py index 6a7b0ca02..fdc4c143a 100644 --- a/tests/integration/profiles/five-safes-crate/test_valid_5src.py +++ b/tests/integration/profiles/five-safes-crate/test_valid_5src.py @@ -14,11 +14,11 @@ # limitations under the License. import logging + import pytest from rocrate_validator import services from rocrate_validator.models import Severity -from tests.conftest import SKIP_LOCAL_DATA_ENTITY_EXISTENCE_CHECK_IDENTIFIER from tests.ro_crates import ValidROC from tests.shared import do_entity_test @@ -28,15 +28,18 @@ # Dynamically fetch the SKIP_WEB_RESOURCE_AVAILABILITY_IDENTIFIER # required as disable_inherited_profiles_reporting does not disable Python checks from # inherited profiles (https://github.com/crs4/rocrate-validator/issues/135) -rocrate_profile = services.get_profile("ro-crate") +rocrate_profile = services.get_profile("ro-crate-1.2") if not rocrate_profile: - raise RuntimeError("Unable to load the RO-Crate profile") + raise RuntimeError("Unable to load the RO-Crate 1.2 profile") +check_local_data_entity_existence = rocrate_profile.get_requirement_check("Data Entity: REQUIRED resource availability") +assert check_local_data_entity_existence, "Unable to find the requirement 'Data Entity: REQUIRED resource availability'" +SKIP_LOCAL_DATA_ENTITY_EXISTENCE_CHECK_IDENTIFIER = check_local_data_entity_existence.identifier check_local_data_entity_existence = rocrate_profile.get_requirement_check( - "Web-based Data Entity: resource availability" + "Web-based Data Entity: REQUIRED resource availability" +) +assert check_local_data_entity_existence, ( + "Unable to find the requirement 'Web-based Data Entity: REQUIRED resource availability'" ) -assert ( - check_local_data_entity_existence -), "Unable to find the requirement 'Web-based Data Entity: resource availability'" SKIP_WEB_RESOURCE_AVAILABILITY_IDENTIFIER = check_local_data_entity_existence.identifier diff --git a/tests/integration/profiles/test_metadata_only.py b/tests/integration/profiles/test_metadata_only.py index b1f4d2662..9f5882824 100644 --- a/tests/integration/profiles/test_metadata_only.py +++ b/tests/integration/profiles/test_metadata_only.py @@ -63,12 +63,9 @@ def test_valid_ro_crates_from_folder(valid_roc_path): [], [], profile_identifier=( - # ro-crate-1.1 can't be used for Five Safes crates as they conform to 1.2 - "five-safes-crate" - if "five-safes-crate" in valid_roc_path.name - else DEFAULT_PROFILE_IDENTIFIER + "five-safes-crate" if "five-safes-crate" in valid_roc_path.name else DEFAULT_PROFILE_IDENTIFIER ), - metadata_only=True + metadata_only=True, ) @@ -89,11 +86,8 @@ def test_valid_ro_crates_from_metadata_dict(valid_roc_path): [], [], profile_identifier=( - # ro-crate-1.1 can't be used for Five Safes crates as they conform to 1.2 - "five-safes-crate" - if "five-safes-crate" in valid_roc_path.name - else DEFAULT_PROFILE_IDENTIFIER + "five-safes-crate" if "five-safes-crate" in valid_roc_path.name else DEFAULT_PROFILE_IDENTIFIER ), metadata_dict=metadata_dict, - metadata_only=True + metadata_only=True, ) diff --git a/tests/ro_crates.py b/tests/ro_crates.py index 0bdcdfe9e..4a450c9d0 100644 --- a/tests/ro_crates.py +++ b/tests/ro_crates.py @@ -1004,8 +1004,7 @@ def propertyvalue_no_unitcode(self) -> Path: class Invalid5sROC: - - base_path = INVALID_CRATES_DATA_PATH / "five_safes_crate/" + base_path = INVALID_CRATES_DATA_PATH / "five_safes_crate" @property def context_multiple_wrong_version(self) -> Path: diff --git a/tests/shared.py b/tests/shared.py index 7752d1d81..9893c3766 100644 --- a/tests/shared.py +++ b/tests/shared.py @@ -40,7 +40,7 @@ PREFIX schema: PREFIX shp: PREFIX rdf: -PREFIX rocrate: +PREFIX rocrate: PREFIX dct: """ @@ -50,7 +50,6 @@ def first(c: Collection[T]) -> T: def load_graph_and_preserve_relative_ids(json_data, base="http://example.org/"): - rel_ids = set() def collect_ids(obj): @@ -79,16 +78,20 @@ def replace_uri_in_graph(graph, old_uri_str, new_uri_str): new = rdflib.URIRef(new_uri_str) triples_to_add = [] triples_to_remove = [] + for s, p, o in graph.triples((None, None, None)): s2 = new if (isinstance(s, rdflib.URIRef) and str(s) == old_uri_str) else s o2 = new if (isinstance(o, rdflib.URIRef) and str(o) == old_uri_str) else o + if (s2, p, o2) != (s, p, o): triples_to_remove.append((s, p, o)) triples_to_add.append((s2, p, o2)) - for t in triples_to_remove: - graph.remove(t) - for t in triples_to_add: - graph.add(t) + + for triple in triples_to_remove: + graph.remove(triple) + + for triple in triples_to_add: + graph.add(triple) for expanded, rel in mapping.items(): replace_uri_in_graph(g, expanded, rel) @@ -98,10 +101,9 @@ def replace_uri_in_graph(graph, old_uri_str, new_uri_str): def _uses_https_schema(graph: rdflib.Graph) -> bool: for s, p, o in graph.triples((None, None, None)): for term in (s, p, o): - if isinstance(term, rdflib.URIRef) and str(term).startswith( - "https://schema.org/" - ): + if isinstance(term, rdflib.URIRef) and str(term).startswith("https://schema.org/"): return True + return False @@ -167,13 +169,13 @@ def do_entity_test( # pylint: disable=too-many-locals """ Shared function to test a RO-Crate entity. - Additional keyword arguments (kwargs) are passed along to initialise ValidationSettings. + Additional keyword arguments (kwargs) are passed along to initialise + ValidationSettings. """ assert not (rocrate_entity_patch and rocrate_entity_mod_sparql), ( "Cannot use rocrate_entity_patch and rocrate_entity_mod_sparql together" ) - # declare variables failed_requirements = None detected_issues = None @@ -191,6 +193,7 @@ def do_entity_test( # pylint: disable=too-many-locals if expected_triggered_requirements is None: expected_triggered_requirements = [] + if expected_triggered_issues is None: expected_triggered_issues = [] @@ -214,7 +217,11 @@ def do_entity_test( # pylint: disable=too-many-locals **kwargs, ) ) - logger.debug("Expected validation result: %s", expected_validation_result) + + logger.debug( + "Expected validation result: %s", + expected_validation_result, + ) assert result.context is not None, "Validation context should not be None" logger.debug( @@ -229,7 +236,6 @@ def do_entity_test( # pylint: disable=too-many-locals # check requirement failed_requirements = [_.name for _ in result.failed_requirements] - # check that the expected requirements are triggered for expected_triggered_requirement in expected_triggered_requirements: if expected_triggered_requirement not in failed_requirements: raise AssertionError( @@ -237,12 +243,13 @@ def do_entity_test( # pylint: disable=too-many-locals f'"{expected_triggered_requirement}" was not found in the failed requirements' ) - # check requirement issues detected_issues = [ issue.message for issue in result.get_issues(requirement_severity) if issue.message is not None ] + logger.debug("Detected issues: %s", detected_issues) logger.debug("Expected issues: %s", expected_triggered_issues) + for expected_issue in expected_triggered_issues: if not any(expected_issue in issue for issue in detected_issues): # support partial match raise AssertionError(f'The expected issue "{expected_issue}" was not found in the detected issues') @@ -257,7 +264,9 @@ def do_entity_test( # pylint: disable=too-many-locals logger.debug("Detected issues: %s", detected_issues) raise finally: - # cleanup if temp_rocrate_path is not None: - logger.debug("Cleaning up temporary RO-Crate @ path: %s", temp_rocrate_path) + logger.debug( + "Cleaning up temporary RO-Crate @ path: %s", + temp_rocrate_path, + ) shutil.rmtree(temp_rocrate_path)