From 22818f16f514aa3c3e1ebbc20c8831790f16f9b0 Mon Sep 17 00:00:00 2001 From: simleo Date: Fri, 26 Jul 2024 17:08:44 +0200 Subject: [PATCH 01/11] wtroc: profile.ttl --- .../workflow-testing-ro-crate/profile.ttl | 67 +++++++++++++++++++ 1 file changed, 67 insertions(+) create mode 100644 rocrate_validator/profiles/workflow-testing-ro-crate/profile.ttl diff --git a/rocrate_validator/profiles/workflow-testing-ro-crate/profile.ttl b/rocrate_validator/profiles/workflow-testing-ro-crate/profile.ttl new file mode 100644 index 0000000..0b7d64f --- /dev/null +++ b/rocrate_validator/profiles/workflow-testing-ro-crate/profile.ttl @@ -0,0 +1,67 @@ +@prefix dct: . +@prefix prof: . +@prefix role: . +@prefix rdfs: . + + + + + a prof:Profile ; + + # the Profile's label + rdfs:label "Workflow Testing RO-Crate Metadata Specification 0.1" ; + + # regular metadata, a basic description of the Profile + rdfs:comment """Workflow RO-Crate Metadata Specification."""@en ; + + # URI of the publisher of the Workflow RO-Crate Metadata Specification + dct:publisher ; + + # This profile is an extension of Workflow RO-Crate + prof:isProfileOf ; + + # This profile is a transitive profile of Workflow RO-Crate and the RO-Crate Metadata Specification + prof:isTransitiveProfileOf , ; + + # this profile has a JSON-LD context resource + prof:hasResource [ + a prof:ResourceDescriptor ; + + # it's in JSON-LD format + dct:format ; + + # it conforms to JSON-LD, here refered to by its namespace URI as a Profile + dct:conformsTo ; + + # this profile resource plays the role of "Vocabulary" + # described in this ontology's accompanying Roles vocabulary + prof:hasRole role:Vocabulary ; + + # this profile resource's actual file + prof:hasArtifact ; + ] ; + + # this profile has a human-readable documentation resource + prof:hasResource [ + a prof:ResourceDescriptor ; + + # it's in HTML format + dct:format ; + + # it conforms to HTML, here refered to by its namespace URI as a Profile + dct:conformsTo ; + + # this profile resource plays the role of "Specification" + # described in this ontology's accompanying Roles vocabulary + prof:hasRole role:Specification ; + + # this profile resource's actual file + prof:hasArtifact ; + + # this profile is inherited from the RO-Crate Metadata Specification 1.1 + prof:isInheritedFrom ; + ] ; + + # a short code to refer to the Profile with when a URI can't be used + prof:hasToken "workflow-testing-ro-crate" ; +. From 2a3cadba59f880f53620f743d36412fb5e387dfd Mon Sep 17 00:00:00 2001 From: simleo Date: Mon, 16 Sep 2024 16:18:06 +0200 Subject: [PATCH 02/11] wtroc: update profile.ttl --- .../workflow-testing-ro-crate/profile.ttl | 33 +++++++++++++------ 1 file changed, 23 insertions(+), 10 deletions(-) diff --git a/rocrate_validator/profiles/workflow-testing-ro-crate/profile.ttl b/rocrate_validator/profiles/workflow-testing-ro-crate/profile.ttl index 0b7d64f..7e0c516 100644 --- a/rocrate_validator/profiles/workflow-testing-ro-crate/profile.ttl +++ b/rocrate_validator/profiles/workflow-testing-ro-crate/profile.ttl @@ -1,27 +1,40 @@ +# Copyright (c) 2024 CRS4 +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + @prefix dct: . @prefix prof: . @prefix role: . @prefix rdfs: . - - - + a prof:Profile ; # the Profile's label - rdfs:label "Workflow Testing RO-Crate Metadata Specification 0.1" ; + rdfs:label "Workflow Testing RO-Crate 0.1" ; # regular metadata, a basic description of the Profile - rdfs:comment """Workflow RO-Crate Metadata Specification."""@en ; + rdfs:comment """Workflow Testing RO-Crate Metadata Specification 0.1"""@en ; - # URI of the publisher of the Workflow RO-Crate Metadata Specification - dct:publisher ; + # URI of the publisher of the Specification + dct:publisher ; # This profile is an extension of Workflow RO-Crate prof:isProfileOf ; # This profile is a transitive profile of Workflow RO-Crate and the RO-Crate Metadata Specification - prof:isTransitiveProfileOf , ; + prof:isTransitiveProfileOf , + ; # this profile has a JSON-LD context resource prof:hasResource [ @@ -56,9 +69,9 @@ prof:hasRole role:Specification ; # this profile resource's actual file - prof:hasArtifact ; + prof:hasArtifact ; - # this profile is inherited from the RO-Crate Metadata Specification 1.1 + # this profile is inherited from Workflow RO-Crate prof:isInheritedFrom ; ] ; From ba0f73ccb1ccb6a64cadd757aaa65a8f5aa0e40e Mon Sep 17 00:00:00 2001 From: simleo Date: Mon, 16 Sep 2024 17:26:50 +0200 Subject: [PATCH 03/11] wtroc: add two shapes --- .../must/1_test_suite.ttl | 35 +++++++++++++++++++ .../must/2_root_data_entity_metadata.ttl | 34 ++++++++++++++++++ 2 files changed, 69 insertions(+) create mode 100644 rocrate_validator/profiles/workflow-testing-ro-crate/must/1_test_suite.ttl create mode 100644 rocrate_validator/profiles/workflow-testing-ro-crate/must/2_root_data_entity_metadata.ttl diff --git a/rocrate_validator/profiles/workflow-testing-ro-crate/must/1_test_suite.ttl b/rocrate_validator/profiles/workflow-testing-ro-crate/must/1_test_suite.ttl new file mode 100644 index 0000000..aa3049c --- /dev/null +++ b/rocrate_validator/profiles/workflow-testing-ro-crate/must/1_test_suite.ttl @@ -0,0 +1,35 @@ +# Copyright (c) 2024 CRS4 +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +@prefix ro: <./> . +@prefix ro-crate: . +@prefix workflow-testing-ro-crate: . +@prefix schema: . +@prefix bioschemas: . +@prefix sh: . +@prefix wftest: . + +workflow-testing-ro-crate:WTROCTestSuiteRequired a sh:NodeShape ; + sh:name "Workflow Testing RO-Crate Action MUST" ; + sh:description "Required properties of the Workflow Testing RO-Crate TestSuite" ; + sh:targetClass wftest:TestSuite ; + sh:property [ + a sh:PropertyShape ; + sh:name "TestSuite MUST be referenced via mentions from root" ; + sh:description "The TestSuite MUST be referenced from the Root Data Entity via mentions" ; + sh:path [ sh:inversePath schema:mentions ] ; + sh:node ro-crate:RootDataEntity ; + sh:minCount 1 ; + sh:message "The TestSuite MUST be referenced from the Root Data Entity via mentions" ; + ] . diff --git a/rocrate_validator/profiles/workflow-testing-ro-crate/must/2_root_data_entity_metadata.ttl b/rocrate_validator/profiles/workflow-testing-ro-crate/must/2_root_data_entity_metadata.ttl new file mode 100644 index 0000000..40d9184 --- /dev/null +++ b/rocrate_validator/profiles/workflow-testing-ro-crate/must/2_root_data_entity_metadata.ttl @@ -0,0 +1,34 @@ +# Copyright (c) 2024 CRS4 +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +@prefix ro: <./> . +@prefix ro-crate: . +@prefix schema: . +@prefix sh: . +@prefix wftest: . +@prefix workflow-testing-ro-crate: . + +workflow-testing-ro-crate:WTROCRootDataEntityMetadata a sh:NodeShape ; + sh:name "Root Data Entity Metadata" ; + sh:description "Properties of the Root Data Entity" ; + sh:targetClass ro-crate:RootDataEntity ; + sh:property [ + a sh:PropertyShape ; + sh:name "Root Data Entity mentions" ; + sh:description "The Root Data Entity MUST refer to one or more test suites via mentions" ; + sh:path schema:mentions ; + sh:class wftest:TestSuite; + sh:minCount 1 ; + sh:message "The Root Data Entity MUST refer to one or more test suites via mentions" ; + ] . From d853b6e801ddfea345945ac99de6417f5856cd5a Mon Sep 17 00:00:00 2001 From: simleo Date: Tue, 17 Sep 2024 12:23:20 +0200 Subject: [PATCH 04/11] wtroc: add some tests --- .../ro-crate-metadata.json | 156 ++++++++++++++++++ .../sort-and-change-case.ga | 118 +++++++++++++ .../ro-crate-metadata.json | 133 +++++++++++++++ .../sort-and-change-case-tests.yml | 8 + .../sort-and-change-case.ga | 118 +++++++++++++ .../test_valid_wtroc.py | 31 ++++ .../test_wtroc_root_data_entity.py | 37 +++++ .../test_wtroc_testsuite.py | 37 +++++ tests/ro_crates.py | 13 ++ 9 files changed, 651 insertions(+) create mode 100644 tests/data/crates/invalid/5_workflow_testing_ro_crate/testsuite_not_mentioned/ro-crate-metadata.json create mode 100644 tests/data/crates/invalid/5_workflow_testing_ro_crate/testsuite_not_mentioned/sort-and-change-case.ga create mode 100644 tests/data/crates/valid/workflow-testing-ro-crate/ro-crate-metadata.json create mode 100644 tests/data/crates/valid/workflow-testing-ro-crate/sort-and-change-case-tests.yml create mode 100644 tests/data/crates/valid/workflow-testing-ro-crate/sort-and-change-case.ga create mode 100644 tests/integration/profiles/workflow-testing-ro-crate/test_valid_wtroc.py create mode 100644 tests/integration/profiles/workflow-testing-ro-crate/test_wtroc_root_data_entity.py create mode 100644 tests/integration/profiles/workflow-testing-ro-crate/test_wtroc_testsuite.py diff --git a/tests/data/crates/invalid/5_workflow_testing_ro_crate/testsuite_not_mentioned/ro-crate-metadata.json b/tests/data/crates/invalid/5_workflow_testing_ro_crate/testsuite_not_mentioned/ro-crate-metadata.json new file mode 100644 index 0000000..8428b45 --- /dev/null +++ b/tests/data/crates/invalid/5_workflow_testing_ro_crate/testsuite_not_mentioned/ro-crate-metadata.json @@ -0,0 +1,156 @@ +{ + "@context": [ + "https://w3id.org/ro/crate/1.1/context", + "https://w3id.org/ro/terms/test" + ], + "@graph": [ + { + "@id": "ro-crate-metadata.json", + "@type": "CreativeWork", + "about": { + "@id": "./" + }, + "conformsTo": [ + { + "@id": "https://w3id.org/ro/crate/1.1" + }, + { + "@id": "https://w3id.org/workflowhub/workflow-ro-crate/1.0" + } + ] + }, + { + "@id": "./", + "@type": "Dataset", + "datePublished": "2024-09-17T11:09:44+00:00", + "hasPart": [ + { + "@id": "sort-and-change-case.ga" + }, + { + "@id": "sort-and-change-case-tests.yml" + } + ], + "license": { + "@id": "https://spdx.org/licenses/Apache-2.0.html" + }, + "mainEntity": { + "@id": "sort-and-change-case.ga" + }, + "mentions": [ + { + "@id": "#test1" + } + ] + }, + { + "@id": "https://spdx.org/licenses/Apache-2.0.html", + "@type": "CreativeWork", + "name": "Apache 2.0 license" + }, + { + "@id": "sort-and-change-case.ga", + "@type": [ + "File", + "SoftwareSourceCode", + "ComputationalWorkflow" + ], + "conformsTo": { + "@id": "https://bioschemas.org/profiles/ComputationalWorkflow/1.0-RELEASE" + }, + "description": "sort lines and change text to upper case", + "license": "https://spdx.org/licenses/MIT.html", + "name": "sort-and-change-case", + "programmingLanguage": { + "@id": "https://w3id.org/workflowhub/workflow-ro-crate#galaxy" + } + }, + { + "@id": "https://w3id.org/workflowhub/workflow-ro-crate#galaxy", + "@type": "ComputerLanguage", + "identifier": { + "@id": "https://galaxyproject.org/" + }, + "name": "Galaxy", + "url": { + "@id": "https://galaxyproject.org/" + } + }, + { + "@id": "#test1", + "name": "test1", + "@type": "TestSuite", + "mainEntity": { + "@id": "sort-and-change-case.ga" + }, + "instance": [ + { + "@id": "#test1_1" + } + ], + "definition": { + "@id": "sort-and-change-case-tests.yml" + } + }, + { + "@id": "#test2", + "name": "test2", + "@type": "TestSuite", + "mainEntity": { + "@id": "sort-and-change-case.ga" + }, + "instance": [ + { + "@id": "#test2_1" + } + ] + }, + { + "@id": "#test1_1", + "name": "test1_1", + "@type": "TestInstance", + "runsOn": { + "@id": "https://w3id.org/ro/terms/test#JenkinsService" + }, + "url": "http://example.org/jenkins", + "resource": "job/tests/" + }, + { + "@id": "#test2_1", + "name": "test2_1", + "@type": "TestInstance", + "runsOn": { + "@id": "https://w3id.org/ro/terms/test#JenkinsService" + }, + "url": "http://example.org/jenkins", + "resource": "job/moretests/" + }, + { + "@id": "https://w3id.org/ro/terms/test#JenkinsService", + "@type": "TestService", + "name": "Jenkins", + "url": { + "@id": "https://www.jenkins.io" + } + }, + { + "@id": "sort-and-change-case-tests.yml", + "@type": [ + "File", + "TestDefinition" + ], + "conformsTo": { + "@id": "https://w3id.org/ro/terms/test#PlanemoEngine" + }, + "engineVersion": ">=0.70" + }, + { + "@id": "https://w3id.org/ro/terms/test#PlanemoEngine", + "@type": "SoftwareApplication", + "name": "Planemo", + "url": { + "@id": "https://github.com/galaxyproject/planemo" + } + } + ] +} diff --git a/tests/data/crates/invalid/5_workflow_testing_ro_crate/testsuite_not_mentioned/sort-and-change-case.ga b/tests/data/crates/invalid/5_workflow_testing_ro_crate/testsuite_not_mentioned/sort-and-change-case.ga new file mode 100644 index 0000000..5a19996 --- /dev/null +++ b/tests/data/crates/invalid/5_workflow_testing_ro_crate/testsuite_not_mentioned/sort-and-change-case.ga @@ -0,0 +1,118 @@ +{ + "uuid": "e2a8566c-c025-4181-9e90-7ed29d4e4df1", + "tags": [], + "format-version": "0.1", + "name": "sort-and-change-case", + "version": 0, + "steps": { + "0": { + "tool_id": null, + "tool_version": null, + "outputs": [], + "workflow_outputs": [], + "input_connections": {}, + "tool_state": "{}", + "id": 0, + "uuid": "5a36fad2-66c7-4b9e-8759-0fbcae9b8541", + "errors": null, + "name": "Input dataset", + "label": "bed_input", + "inputs": [], + "position": { + "top": 200, + "left": 200 + }, + "annotation": "", + "content_id": null, + "type": "data_input" + }, + "1": { + "tool_id": "sort1", + "tool_version": "1.1.0", + "outputs": [ + { + "type": "input", + "name": "out_file1" + } + ], + "workflow_outputs": [ + { + "output_name": "out_file1", + "uuid": "8237f71a-bc2a-494e-a63c-09c1e65ef7c8", + "label": "sorted_bed" + } + ], + "input_connections": { + "input": { + "output_name": "output", + "id": 0 + } + }, + "tool_state": "{\"__page__\": null, \"style\": \"\\\"alpha\\\"\", \"column\": \"\\\"1\\\"\", \"__rerun_remap_job_id__\": null, \"column_set\": \"[]\", \"input\": \"{\\\"__class__\\\": \\\"RuntimeValue\\\"}\", \"header_lines\": \"\\\"0\\\"\", \"order\": \"\\\"ASC\\\"\"}", + "id": 1, + "uuid": "0b6b3cda-c75f-452b-85b1-8ae4f3302ba4", + "errors": null, + "name": "Sort", + "post_job_actions": {}, + "label": "sort", + "inputs": [ + { + "name": "input", + "description": "runtime parameter for tool Sort" + } + ], + "position": { + "top": 200, + "left": 420 + }, + "annotation": "", + "content_id": "sort1", + "type": "tool" + }, + "2": { + "tool_id": "ChangeCase", + "tool_version": "1.0.0", + "outputs": [ + { + "type": "tabular", + "name": "out_file1" + } + ], + "workflow_outputs": [ + { + "output_name": "out_file1", + "uuid": "c31cd733-dab6-4d50-9fec-b644d162397b", + "label": "uppercase_bed" + } + ], + "input_connections": { + "input": { + "output_name": "out_file1", + "id": 1 + } + }, + "tool_state": "{\"__page__\": null, \"casing\": \"\\\"up\\\"\", \"__rerun_remap_job_id__\": null, \"cols\": \"\\\"c1\\\"\", \"delimiter\": \"\\\"TAB\\\"\", \"input\": \"{\\\"__class__\\\": \\\"RuntimeValue\\\"}\"}", + "id": 2, + "uuid": "9698bcde-0729-48fe-b88d-ccfb6f6153b4", + "errors": null, + "name": "Change Case", + "post_job_actions": {}, + "label": "change_case", + "inputs": [ + { + "name": "input", + "description": "runtime parameter for tool Change Case" + } + ], + "position": { + "top": 200, + "left": 640 + }, + "annotation": "", + "content_id": "ChangeCase", + "type": "tool" + } + }, + "annotation": "", + "a_galaxy_workflow": "true" +} diff --git a/tests/data/crates/valid/workflow-testing-ro-crate/ro-crate-metadata.json b/tests/data/crates/valid/workflow-testing-ro-crate/ro-crate-metadata.json new file mode 100644 index 0000000..465d12d --- /dev/null +++ b/tests/data/crates/valid/workflow-testing-ro-crate/ro-crate-metadata.json @@ -0,0 +1,133 @@ +{ + "@context": [ + "https://w3id.org/ro/crate/1.1/context", + "https://w3id.org/ro/terms/test" + ], + "@graph": [ + { + "@id": "ro-crate-metadata.json", + "@type": "CreativeWork", + "about": { + "@id": "./" + }, + "conformsTo": [ + { + "@id": "https://w3id.org/ro/crate/1.1" + }, + { + "@id": "https://w3id.org/workflowhub/workflow-ro-crate/1.0" + } + ] + }, + { + "@id": "./", + "@type": "Dataset", + "datePublished": "2024-09-17T11:09:44+00:00", + "hasPart": [ + { + "@id": "sort-and-change-case.ga" + }, + { + "@id": "sort-and-change-case-tests.yml" + } + ], + "license": { + "@id": "https://spdx.org/licenses/Apache-2.0.html" + }, + "mainEntity": { + "@id": "sort-and-change-case.ga" + }, + "mentions": [ + { + "@id": "#test1" + } + ] + }, + { + "@id": "https://spdx.org/licenses/Apache-2.0.html", + "@type": "CreativeWork", + "name": "Apache 2.0 license" + }, + { + "@id": "sort-and-change-case.ga", + "@type": [ + "File", + "SoftwareSourceCode", + "ComputationalWorkflow" + ], + "conformsTo": { + "@id": "https://bioschemas.org/profiles/ComputationalWorkflow/1.0-RELEASE" + }, + "description": "sort lines and change text to upper case", + "license": "https://spdx.org/licenses/MIT.html", + "name": "sort-and-change-case", + "programmingLanguage": { + "@id": "https://w3id.org/workflowhub/workflow-ro-crate#galaxy" + } + }, + { + "@id": "https://w3id.org/workflowhub/workflow-ro-crate#galaxy", + "@type": "ComputerLanguage", + "identifier": { + "@id": "https://galaxyproject.org/" + }, + "name": "Galaxy", + "url": { + "@id": "https://galaxyproject.org/" + } + }, + { + "@id": "#test1", + "name": "test1", + "@type": "TestSuite", + "mainEntity": { + "@id": "sort-and-change-case.ga" + }, + "instance": [ + { + "@id": "#test1_1" + } + ], + "definition": { + "@id": "sort-and-change-case-tests.yml" + } + }, + { + "@id": "#test1_1", + "name": "test1_1", + "@type": "TestInstance", + "runsOn": { + "@id": "https://w3id.org/ro/terms/test#JenkinsService" + }, + "url": "http://example.org/jenkins", + "resource": "job/tests/" + }, + { + "@id": "https://w3id.org/ro/terms/test#JenkinsService", + "@type": "TestService", + "name": "Jenkins", + "url": { + "@id": "https://www.jenkins.io" + } + }, + { + "@id": "sort-and-change-case-tests.yml", + "@type": [ + "File", + "TestDefinition" + ], + "conformsTo": { + "@id": "https://w3id.org/ro/terms/test#PlanemoEngine" + }, + "engineVersion": ">=0.70" + }, + { + "@id": "https://w3id.org/ro/terms/test#PlanemoEngine", + "@type": "SoftwareApplication", + "name": "Planemo", + "url": { + "@id": "https://github.com/galaxyproject/planemo" + } + } + ] +} diff --git a/tests/data/crates/valid/workflow-testing-ro-crate/sort-and-change-case-tests.yml b/tests/data/crates/valid/workflow-testing-ro-crate/sort-and-change-case-tests.yml new file mode 100644 index 0000000..9f24ba6 --- /dev/null +++ b/tests/data/crates/valid/workflow-testing-ro-crate/sort-and-change-case-tests.yml @@ -0,0 +1,8 @@ +- doc: test with a small input + job: + bed_input: + class: File + path: http://example.com/data/input.bed + outputs: + uppercase_bed: + path: http://example.com/data/output_exp.bed diff --git a/tests/data/crates/valid/workflow-testing-ro-crate/sort-and-change-case.ga b/tests/data/crates/valid/workflow-testing-ro-crate/sort-and-change-case.ga new file mode 100644 index 0000000..5a19996 --- /dev/null +++ b/tests/data/crates/valid/workflow-testing-ro-crate/sort-and-change-case.ga @@ -0,0 +1,118 @@ +{ + "uuid": "e2a8566c-c025-4181-9e90-7ed29d4e4df1", + "tags": [], + "format-version": "0.1", + "name": "sort-and-change-case", + "version": 0, + "steps": { + "0": { + "tool_id": null, + "tool_version": null, + "outputs": [], + "workflow_outputs": [], + "input_connections": {}, + "tool_state": "{}", + "id": 0, + "uuid": "5a36fad2-66c7-4b9e-8759-0fbcae9b8541", + "errors": null, + "name": "Input dataset", + "label": "bed_input", + "inputs": [], + "position": { + "top": 200, + "left": 200 + }, + "annotation": "", + "content_id": null, + "type": "data_input" + }, + "1": { + "tool_id": "sort1", + "tool_version": "1.1.0", + "outputs": [ + { + "type": "input", + "name": "out_file1" + } + ], + "workflow_outputs": [ + { + "output_name": "out_file1", + "uuid": "8237f71a-bc2a-494e-a63c-09c1e65ef7c8", + "label": "sorted_bed" + } + ], + "input_connections": { + "input": { + "output_name": "output", + "id": 0 + } + }, + "tool_state": "{\"__page__\": null, \"style\": \"\\\"alpha\\\"\", \"column\": \"\\\"1\\\"\", \"__rerun_remap_job_id__\": null, \"column_set\": \"[]\", \"input\": \"{\\\"__class__\\\": \\\"RuntimeValue\\\"}\", \"header_lines\": \"\\\"0\\\"\", \"order\": \"\\\"ASC\\\"\"}", + "id": 1, + "uuid": "0b6b3cda-c75f-452b-85b1-8ae4f3302ba4", + "errors": null, + "name": "Sort", + "post_job_actions": {}, + "label": "sort", + "inputs": [ + { + "name": "input", + "description": "runtime parameter for tool Sort" + } + ], + "position": { + "top": 200, + "left": 420 + }, + "annotation": "", + "content_id": "sort1", + "type": "tool" + }, + "2": { + "tool_id": "ChangeCase", + "tool_version": "1.0.0", + "outputs": [ + { + "type": "tabular", + "name": "out_file1" + } + ], + "workflow_outputs": [ + { + "output_name": "out_file1", + "uuid": "c31cd733-dab6-4d50-9fec-b644d162397b", + "label": "uppercase_bed" + } + ], + "input_connections": { + "input": { + "output_name": "out_file1", + "id": 1 + } + }, + "tool_state": "{\"__page__\": null, \"casing\": \"\\\"up\\\"\", \"__rerun_remap_job_id__\": null, \"cols\": \"\\\"c1\\\"\", \"delimiter\": \"\\\"TAB\\\"\", \"input\": \"{\\\"__class__\\\": \\\"RuntimeValue\\\"}\"}", + "id": 2, + "uuid": "9698bcde-0729-48fe-b88d-ccfb6f6153b4", + "errors": null, + "name": "Change Case", + "post_job_actions": {}, + "label": "change_case", + "inputs": [ + { + "name": "input", + "description": "runtime parameter for tool Change Case" + } + ], + "position": { + "top": 200, + "left": 640 + }, + "annotation": "", + "content_id": "ChangeCase", + "type": "tool" + } + }, + "annotation": "", + "a_galaxy_workflow": "true" +} diff --git a/tests/integration/profiles/workflow-testing-ro-crate/test_valid_wtroc.py b/tests/integration/profiles/workflow-testing-ro-crate/test_valid_wtroc.py new file mode 100644 index 0000000..b61cbf0 --- /dev/null +++ b/tests/integration/profiles/workflow-testing-ro-crate/test_valid_wtroc.py @@ -0,0 +1,31 @@ +# Copyright (c) 2024 CRS4 +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import logging + +from rocrate_validator.models import Severity +from tests.ro_crates import ValidROC +from tests.shared import do_entity_test + +logger = logging.getLogger(__name__) + + +def test_valid_workflow_roc_required(): + """Test a valid Workflow Testing RO-Crate.""" + do_entity_test( + ValidROC().workflow_testing_ro_crate, + Severity.REQUIRED, + True, + profile_identifier="workflow-testing-ro-crate" + ) diff --git a/tests/integration/profiles/workflow-testing-ro-crate/test_wtroc_root_data_entity.py b/tests/integration/profiles/workflow-testing-ro-crate/test_wtroc_root_data_entity.py new file mode 100644 index 0000000..517efbf --- /dev/null +++ b/tests/integration/profiles/workflow-testing-ro-crate/test_wtroc_root_data_entity.py @@ -0,0 +1,37 @@ +# Copyright (c) 2024 CRS4 +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import logging + +from rocrate_validator.models import Severity +from tests.ro_crates import ValidROC +from tests.shared import do_entity_test + +# set up logging +logger = logging.getLogger(__name__) + + +def test_wtroc_no_suites(): + """\ + Test a Workflow Testing RO-Crate where the root data entity does not refer to + any TestSuite via mentions. + """ + do_entity_test( + ValidROC().workflow_roc, # a plain workflow ro-crate, no test suites + Severity.REQUIRED, + False, + ["Root Data Entity Metadata"], + ["The Root Data Entity MUST refer to one or more test suites via mentions"], + profile_identifier="workflow-testing-ro-crate" + ) diff --git a/tests/integration/profiles/workflow-testing-ro-crate/test_wtroc_testsuite.py b/tests/integration/profiles/workflow-testing-ro-crate/test_wtroc_testsuite.py new file mode 100644 index 0000000..1f7522c --- /dev/null +++ b/tests/integration/profiles/workflow-testing-ro-crate/test_wtroc_testsuite.py @@ -0,0 +1,37 @@ +# Copyright (c) 2024 CRS4 +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import logging + +from rocrate_validator.models import Severity +from tests.ro_crates import InvalidWTROC +from tests.shared import do_entity_test + +# set up logging +logger = logging.getLogger(__name__) + + +def test_wtroc_testsuite_not_mentioned(): + """\ + Test a Workflow Testing RO-Crate where a TestSuite is not listed in the + Root Data Entity's mentions. + """ + do_entity_test( + InvalidWTROC().testsuite_not_mentioned, + Severity.REQUIRED, + False, + ["Workflow Testing RO-Crate Action MUST"], + ["The TestSuite MUST be referenced from the Root Data Entity via mentions"], + profile_identifier="workflow-testing-ro-crate" + ) diff --git a/tests/ro_crates.py b/tests/ro_crates.py index d5885de..d6df6b5 100644 --- a/tests/ro_crates.py +++ b/tests/ro_crates.py @@ -66,6 +66,10 @@ def process_run_crate_collections(self) -> Path: def process_run_crate_containerimage(self) -> Path: return VALID_CRATES_DATA_PATH / "process-run-crate-containerimage" + @property + def workflow_testing_ro_crate(self) -> Path: + return VALID_CRATES_DATA_PATH / "workflow-testing-ro-crate" + class InvalidFileDescriptor: @@ -463,3 +467,12 @@ def softwareapplication_no_softwarerequirements(self) -> Path: @property def softwareapplication_bad_softwarerequirements(self) -> Path: return self.base_path / "softwareapplication_bad_softwarerequirements" + + +class InvalidWTROC: + + base_path = INVALID_CRATES_DATA_PATH / "5_workflow_testing_ro_crate/" + + @property + def testsuite_not_mentioned(self) -> Path: + return self.base_path / "testsuite_not_mentioned" From be41b3be6125e11590241d93205b7574ae49006f Mon Sep 17 00:00:00 2001 From: simleo Date: Tue, 17 Sep 2024 14:55:30 +0200 Subject: [PATCH 05/11] wtroc: fix shape name --- .../profiles/workflow-testing-ro-crate/must/1_test_suite.ttl | 2 +- .../profiles/workflow-testing-ro-crate/test_wtroc_testsuite.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/rocrate_validator/profiles/workflow-testing-ro-crate/must/1_test_suite.ttl b/rocrate_validator/profiles/workflow-testing-ro-crate/must/1_test_suite.ttl index aa3049c..291b8bd 100644 --- a/rocrate_validator/profiles/workflow-testing-ro-crate/must/1_test_suite.ttl +++ b/rocrate_validator/profiles/workflow-testing-ro-crate/must/1_test_suite.ttl @@ -21,7 +21,7 @@ @prefix wftest: . workflow-testing-ro-crate:WTROCTestSuiteRequired a sh:NodeShape ; - sh:name "Workflow Testing RO-Crate Action MUST" ; + sh:name "Workflow Testing RO-Crate TestSuite MUST" ; sh:description "Required properties of the Workflow Testing RO-Crate TestSuite" ; sh:targetClass wftest:TestSuite ; sh:property [ diff --git a/tests/integration/profiles/workflow-testing-ro-crate/test_wtroc_testsuite.py b/tests/integration/profiles/workflow-testing-ro-crate/test_wtroc_testsuite.py index 1f7522c..7b5e441 100644 --- a/tests/integration/profiles/workflow-testing-ro-crate/test_wtroc_testsuite.py +++ b/tests/integration/profiles/workflow-testing-ro-crate/test_wtroc_testsuite.py @@ -31,7 +31,7 @@ def test_wtroc_testsuite_not_mentioned(): InvalidWTROC().testsuite_not_mentioned, Severity.REQUIRED, False, - ["Workflow Testing RO-Crate Action MUST"], + ["Workflow Testing RO-Crate TestSuite MUST"], ["The TestSuite MUST be referenced from the Root Data Entity via mentions"], profile_identifier="workflow-testing-ro-crate" ) From de309f6a490edc37f88b42d4c5ef0172cbbe0de2 Mon Sep 17 00:00:00 2001 From: simleo Date: Tue, 17 Sep 2024 15:39:08 +0200 Subject: [PATCH 06/11] wtroc: add shape to state that suites must have an instance or definition --- .../must/1_test_suite.ttl | 21 +++++ .../ro-crate-metadata.json | 88 +++++++++++++++++++ .../test_wtroc_testsuite.py | 15 ++++ tests/ro_crates.py | 4 + 4 files changed, 128 insertions(+) create mode 100644 tests/data/crates/invalid/5_workflow_testing_ro_crate/testsuite_no_instance_no_def/ro-crate-metadata.json diff --git a/rocrate_validator/profiles/workflow-testing-ro-crate/must/1_test_suite.ttl b/rocrate_validator/profiles/workflow-testing-ro-crate/must/1_test_suite.ttl index 291b8bd..d431ebe 100644 --- a/rocrate_validator/profiles/workflow-testing-ro-crate/must/1_test_suite.ttl +++ b/rocrate_validator/profiles/workflow-testing-ro-crate/must/1_test_suite.ttl @@ -33,3 +33,24 @@ workflow-testing-ro-crate:WTROCTestSuiteRequired a sh:NodeShape ; sh:minCount 1 ; sh:message "The TestSuite MUST be referenced from the Root Data Entity via mentions" ; ] . + + +workflow-testing-ro-crate:WTROCTestSuiteInstanceOrDefinition a sh:NodeShape ; + sh:name "TestSuite instance or definition" ; + sh:description "The TestSuite MUST refer to a TestInstance or TestDefinition" ; + sh:message "The TestSuite MUST refer to a TestInstance or TestDefinition" ; + sh:targetClass wftest:TestSuite ; + sh:or ( + [ sh:property [ + a sh:PropertyShape ; + sh:path wftest:instance ; + sh:class wftest:TestInstance ; + sh:minCount 1 ; + ]] + [ sh:property [ + a sh:PropertyShape ; + sh:path wftest:definition ; + sh:class wftest:TestDefinition ; + sh:minCount 1 ; + ]] + ) . diff --git a/tests/data/crates/invalid/5_workflow_testing_ro_crate/testsuite_no_instance_no_def/ro-crate-metadata.json b/tests/data/crates/invalid/5_workflow_testing_ro_crate/testsuite_no_instance_no_def/ro-crate-metadata.json new file mode 100644 index 0000000..3ecf4dd --- /dev/null +++ b/tests/data/crates/invalid/5_workflow_testing_ro_crate/testsuite_no_instance_no_def/ro-crate-metadata.json @@ -0,0 +1,88 @@ +{ + "@context": [ + "https://w3id.org/ro/crate/1.1/context", + "https://w3id.org/ro/terms/test" + ], + "@graph": [ + { + "@id": "ro-crate-metadata.json", + "@type": "CreativeWork", + "about": { + "@id": "./" + }, + "conformsTo": [ + { + "@id": "https://w3id.org/ro/crate/1.1" + }, + { + "@id": "https://w3id.org/workflowhub/workflow-ro-crate/1.0" + } + ] + }, + { + "@id": "./", + "@type": "Dataset", + "datePublished": "2024-09-17T11:09:44+00:00", + "hasPart": [ + { + "@id": "sort-and-change-case.ga" + }, + { + "@id": "sort-and-change-case-tests.yml" + } + ], + "license": { + "@id": "https://spdx.org/licenses/Apache-2.0.html" + }, + "mainEntity": { + "@id": "sort-and-change-case.ga" + }, + "mentions": [ + { + "@id": "#test1" + } + ] + }, + { + "@id": "https://spdx.org/licenses/Apache-2.0.html", + "@type": "CreativeWork", + "name": "Apache 2.0 license" + }, + { + "@id": "sort-and-change-case.ga", + "@type": [ + "File", + "SoftwareSourceCode", + "ComputationalWorkflow" + ], + "conformsTo": { + "@id": "https://bioschemas.org/profiles/ComputationalWorkflow/1.0-RELEASE" + }, + "description": "sort lines and change text to upper case", + "license": "https://spdx.org/licenses/MIT.html", + "name": "sort-and-change-case", + "programmingLanguage": { + "@id": "https://w3id.org/workflowhub/workflow-ro-crate#galaxy" + } + }, + { + "@id": "https://w3id.org/workflowhub/workflow-ro-crate#galaxy", + "@type": "ComputerLanguage", + "identifier": { + "@id": "https://galaxyproject.org/" + }, + "name": "Galaxy", + "url": { + "@id": "https://galaxyproject.org/" + } + }, + { + "@id": "#test1", + "name": "test1", + "@type": "TestSuite", + "mainEntity": { + "@id": "sort-and-change-case.ga" + } + } + ] +} diff --git a/tests/integration/profiles/workflow-testing-ro-crate/test_wtroc_testsuite.py b/tests/integration/profiles/workflow-testing-ro-crate/test_wtroc_testsuite.py index 7b5e441..7e693e8 100644 --- a/tests/integration/profiles/workflow-testing-ro-crate/test_wtroc_testsuite.py +++ b/tests/integration/profiles/workflow-testing-ro-crate/test_wtroc_testsuite.py @@ -35,3 +35,18 @@ def test_wtroc_testsuite_not_mentioned(): ["The TestSuite MUST be referenced from the Root Data Entity via mentions"], profile_identifier="workflow-testing-ro-crate" ) + + +def test_wtroc_testsuite_no_instance_no_def(): + """\ + Test a Workflow Testing RO-Crate where a TestSuite does not refer to either a + TestSuite or a TestDefinition. + """ + do_entity_test( + InvalidWTROC().testsuite_no_instance_no_def, + Severity.REQUIRED, + False, + ["TestSuite instance or definition"], + ["The TestSuite MUST refer to a TestInstance or TestDefinition"], + profile_identifier="workflow-testing-ro-crate" + ) diff --git a/tests/ro_crates.py b/tests/ro_crates.py index d6df6b5..1bd9eae 100644 --- a/tests/ro_crates.py +++ b/tests/ro_crates.py @@ -476,3 +476,7 @@ class InvalidWTROC: @property def testsuite_not_mentioned(self) -> Path: return self.base_path / "testsuite_not_mentioned" + + @property + def testsuite_no_instance_no_def(self) -> Path: + return self.base_path / "testsuite_no_instance_no_def" From bb9422677b053e15faaba05f41e9ff7f18aa3e4a Mon Sep 17 00:00:00 2001 From: simleo Date: Wed, 18 Sep 2024 15:55:37 +0200 Subject: [PATCH 07/11] wtroc: one more shape for test suite --- .../should/1_test_suite.ttl | 38 +++++ .../ro-crate-metadata.json | 130 ++++++++++++++++++ .../test_wtroc_testsuite.py | 19 ++- tests/ro_crates.py | 4 + 4 files changed, 189 insertions(+), 2 deletions(-) create mode 100644 rocrate_validator/profiles/workflow-testing-ro-crate/should/1_test_suite.ttl create mode 100644 tests/data/crates/invalid/5_workflow_testing_ro_crate/testsuite_no_mainentity/ro-crate-metadata.json diff --git a/rocrate_validator/profiles/workflow-testing-ro-crate/should/1_test_suite.ttl b/rocrate_validator/profiles/workflow-testing-ro-crate/should/1_test_suite.ttl new file mode 100644 index 0000000..f1af48c --- /dev/null +++ b/rocrate_validator/profiles/workflow-testing-ro-crate/should/1_test_suite.ttl @@ -0,0 +1,38 @@ +# Copyright (c) 2024 CRS4 +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +@prefix ro: <./> . +@prefix ro-crate: . +@prefix workflow-testing-ro-crate: . +@prefix schema: . +@prefix bioschemas: . +@prefix sh: . +@prefix wroc: . +@prefix wftest: . + +workflow-testing-ro-crate:WTROCTestSuiteRecommended a sh:NodeShape ; + sh:name "Workflow Testing RO-Crate TestSuite SHOULD" ; + sh:description "Recommended properties of the Workflow Testing RO-Crate TestSuite" ; + sh:targetClass wftest:TestSuite ; + sh:property [ + a sh:PropertyShape ; + sh:name "TestSuite mainEntity" ; + sh:description "The TestSuite SHOULD refer to the tested workflow via mainEntity" ; + sh:path schema:mainEntity ; + sh:class schema:MediaObject , + schema:SoftwareSourceCode , + bioschemas:ComputationalWorkflow ; + sh:minCount 1 ; + sh:message "The TestSuite SHOULD refer to the tested workflow via mainEntity" ; + ] . diff --git a/tests/data/crates/invalid/5_workflow_testing_ro_crate/testsuite_no_mainentity/ro-crate-metadata.json b/tests/data/crates/invalid/5_workflow_testing_ro_crate/testsuite_no_mainentity/ro-crate-metadata.json new file mode 100644 index 0000000..82a2299 --- /dev/null +++ b/tests/data/crates/invalid/5_workflow_testing_ro_crate/testsuite_no_mainentity/ro-crate-metadata.json @@ -0,0 +1,130 @@ +{ + "@context": [ + "https://w3id.org/ro/crate/1.1/context", + "https://w3id.org/ro/terms/test" + ], + "@graph": [ + { + "@id": "ro-crate-metadata.json", + "@type": "CreativeWork", + "about": { + "@id": "./" + }, + "conformsTo": [ + { + "@id": "https://w3id.org/ro/crate/1.1" + }, + { + "@id": "https://w3id.org/workflowhub/workflow-ro-crate/1.0" + } + ] + }, + { + "@id": "./", + "@type": "Dataset", + "datePublished": "2024-09-17T11:09:44+00:00", + "hasPart": [ + { + "@id": "sort-and-change-case.ga" + }, + { + "@id": "sort-and-change-case-tests.yml" + } + ], + "license": { + "@id": "https://spdx.org/licenses/Apache-2.0.html" + }, + "mainEntity": { + "@id": "sort-and-change-case.ga" + }, + "mentions": [ + { + "@id": "#test1" + } + ] + }, + { + "@id": "https://spdx.org/licenses/Apache-2.0.html", + "@type": "CreativeWork", + "name": "Apache 2.0 license" + }, + { + "@id": "sort-and-change-case.ga", + "@type": [ + "File", + "SoftwareSourceCode", + "ComputationalWorkflow" + ], + "conformsTo": { + "@id": "https://bioschemas.org/profiles/ComputationalWorkflow/1.0-RELEASE" + }, + "description": "sort lines and change text to upper case", + "license": "https://spdx.org/licenses/MIT.html", + "name": "sort-and-change-case", + "programmingLanguage": { + "@id": "https://w3id.org/workflowhub/workflow-ro-crate#galaxy" + } + }, + { + "@id": "https://w3id.org/workflowhub/workflow-ro-crate#galaxy", + "@type": "ComputerLanguage", + "identifier": { + "@id": "https://galaxyproject.org/" + }, + "name": "Galaxy", + "url": { + "@id": "https://galaxyproject.org/" + } + }, + { + "@id": "#test1", + "name": "test1", + "@type": "TestSuite", + "instance": [ + { + "@id": "#test1_1" + } + ], + "definition": { + "@id": "sort-and-change-case-tests.yml" + } + }, + { + "@id": "#test1_1", + "name": "test1_1", + "@type": "TestInstance", + "runsOn": { + "@id": "https://w3id.org/ro/terms/test#JenkinsService" + }, + "url": "http://example.org/jenkins", + "resource": "job/tests/" + }, + { + "@id": "https://w3id.org/ro/terms/test#JenkinsService", + "@type": "TestService", + "name": "Jenkins", + "url": { + "@id": "https://www.jenkins.io" + } + }, + { + "@id": "sort-and-change-case-tests.yml", + "@type": [ + "File", + "TestDefinition" + ], + "conformsTo": { + "@id": "https://w3id.org/ro/terms/test#PlanemoEngine" + }, + "engineVersion": ">=0.70" + }, + { + "@id": "https://w3id.org/ro/terms/test#PlanemoEngine", + "@type": "SoftwareApplication", + "name": "Planemo", + "url": { + "@id": "https://github.com/galaxyproject/planemo" + } + } + ] +} diff --git a/tests/integration/profiles/workflow-testing-ro-crate/test_wtroc_testsuite.py b/tests/integration/profiles/workflow-testing-ro-crate/test_wtroc_testsuite.py index 7e693e8..ff673d9 100644 --- a/tests/integration/profiles/workflow-testing-ro-crate/test_wtroc_testsuite.py +++ b/tests/integration/profiles/workflow-testing-ro-crate/test_wtroc_testsuite.py @@ -39,8 +39,8 @@ def test_wtroc_testsuite_not_mentioned(): def test_wtroc_testsuite_no_instance_no_def(): """\ - Test a Workflow Testing RO-Crate where a TestSuite does not refer to either a - TestSuite or a TestDefinition. + Test a Workflow Testing RO-Crate where a TestSuite does not refer to + either a TestSuite or a TestDefinition. """ do_entity_test( InvalidWTROC().testsuite_no_instance_no_def, @@ -50,3 +50,18 @@ def test_wtroc_testsuite_no_instance_no_def(): ["The TestSuite MUST refer to a TestInstance or TestDefinition"], profile_identifier="workflow-testing-ro-crate" ) + + +def test_wtroc_testsuite_no_mainentity(): + """\ + Test a Workflow Testing RO-Crate where a TestSuite does not refer to + the tested workflow via mainEntity. + """ + do_entity_test( + InvalidWTROC().testsuite_no_mainentity, + Severity.RECOMMENDED, + False, + ["Workflow Testing RO-Crate TestSuite SHOULD"], + ["The TestSuite SHOULD refer to the tested workflow via mainEntity"], + profile_identifier="workflow-testing-ro-crate" + ) diff --git a/tests/ro_crates.py b/tests/ro_crates.py index 1bd9eae..a39477e 100644 --- a/tests/ro_crates.py +++ b/tests/ro_crates.py @@ -480,3 +480,7 @@ def testsuite_not_mentioned(self) -> Path: @property def testsuite_no_instance_no_def(self) -> Path: return self.base_path / "testsuite_no_instance_no_def" + + @property + def testsuite_no_mainentity(self) -> Path: + return self.base_path / "testsuite_no_mainentity" From 0b2954b4ba30e15e288fb6c184c44108135ac6fd Mon Sep 17 00:00:00 2001 From: simleo Date: Wed, 18 Sep 2024 17:41:04 +0200 Subject: [PATCH 08/11] wtroc: add shapes for test instance --- .../must/2_test_instance.ttl | 59 +++++++++ .../ro-crate-metadata.json | 122 ++++++++++++++++++ .../test_wtroc_testinstance.py | 37 ++++++ tests/ro_crates.py | 4 + 4 files changed, 222 insertions(+) create mode 100644 rocrate_validator/profiles/workflow-testing-ro-crate/must/2_test_instance.ttl create mode 100644 tests/data/crates/invalid/5_workflow_testing_ro_crate/testinstance_no_service/ro-crate-metadata.json create mode 100644 tests/integration/profiles/workflow-testing-ro-crate/test_wtroc_testinstance.py diff --git a/rocrate_validator/profiles/workflow-testing-ro-crate/must/2_test_instance.ttl b/rocrate_validator/profiles/workflow-testing-ro-crate/must/2_test_instance.ttl new file mode 100644 index 0000000..54565c5 --- /dev/null +++ b/rocrate_validator/profiles/workflow-testing-ro-crate/must/2_test_instance.ttl @@ -0,0 +1,59 @@ +# Copyright (c) 2024 CRS4 +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +@prefix ro: <./> . +@prefix ro-crate: . +@prefix xsd: . +@prefix workflow-testing-ro-crate: . +@prefix schema: . +@prefix sh: . +@prefix wroc: . +@prefix wftest: . + +workflow-testing-ro-crate:WTROCTestInstanceRequired a sh:NodeShape ; + sh:name "Workflow Testing RO-Crate TestInstance MUST" ; + sh:description "Required properties of the Workflow Testing RO-Crate TestInstance" ; + sh:targetClass wftest:TestInstance ; + sh:property [ + a sh:PropertyShape ; + sh:name "TestInstance runsOn" ; + sh:description "The TestInstance MUST refer to a TestService via runsOn" ; + sh:path wftest:runsOn ; + sh:class wftest:TestService ; + sh:or ( + [ sh:hasValue wftest:GithubService ; ] + [ sh:hasValue wftest:TravisService ; ] + [ sh:hasValue wftest:JenkinsService ; ] + ) ; + sh:minCount 1 ; + sh:message "The TestInstance MUST refer to a TestService via runsOn" ; + ] ; + sh:property [ + a sh:PropertyShape ; + sh:name "TestInstance url" ; + sh:description "The TestInstance MUST refer to the test service base URL via url" ; + sh:path schema:url ; + sh:datatype xsd:string ; + sh:pattern "^http.*" ; + sh:minCount 1 ; + sh:message "The TestInstance MUST refer to the test service base URL via url" ; + ] ; sh:property [ + a sh:PropertyShape ; + sh:name "TestInstance resource" ; + sh:description "The TestInstance MUST refer to the relative URL of the test project base URL via resource" ; + sh:path wftest:resource ; + sh:datatype xsd:string ; + sh:minCount 1 ; + sh:message "The TestInstance MUST refer to the relative URL of the test project base URL via resource" ; + ] . diff --git a/tests/data/crates/invalid/5_workflow_testing_ro_crate/testinstance_no_service/ro-crate-metadata.json b/tests/data/crates/invalid/5_workflow_testing_ro_crate/testinstance_no_service/ro-crate-metadata.json new file mode 100644 index 0000000..ad73411 --- /dev/null +++ b/tests/data/crates/invalid/5_workflow_testing_ro_crate/testinstance_no_service/ro-crate-metadata.json @@ -0,0 +1,122 @@ +{ + "@context": [ + "https://w3id.org/ro/crate/1.1/context", + "https://w3id.org/ro/terms/test" + ], + "@graph": [ + { + "@id": "ro-crate-metadata.json", + "@type": "CreativeWork", + "about": { + "@id": "./" + }, + "conformsTo": [ + { + "@id": "https://w3id.org/ro/crate/1.1" + }, + { + "@id": "https://w3id.org/workflowhub/workflow-ro-crate/1.0" + } + ] + }, + { + "@id": "./", + "@type": "Dataset", + "datePublished": "2024-09-17T11:09:44+00:00", + "hasPart": [ + { + "@id": "sort-and-change-case.ga" + }, + { + "@id": "sort-and-change-case-tests.yml" + } + ], + "license": { + "@id": "https://spdx.org/licenses/Apache-2.0.html" + }, + "mainEntity": { + "@id": "sort-and-change-case.ga" + }, + "mentions": [ + { + "@id": "#test1" + } + ] + }, + { + "@id": "https://spdx.org/licenses/Apache-2.0.html", + "@type": "CreativeWork", + "name": "Apache 2.0 license" + }, + { + "@id": "sort-and-change-case.ga", + "@type": [ + "File", + "SoftwareSourceCode", + "ComputationalWorkflow" + ], + "conformsTo": { + "@id": "https://bioschemas.org/profiles/ComputationalWorkflow/1.0-RELEASE" + }, + "description": "sort lines and change text to upper case", + "license": "https://spdx.org/licenses/MIT.html", + "name": "sort-and-change-case", + "programmingLanguage": { + "@id": "https://w3id.org/workflowhub/workflow-ro-crate#galaxy" + } + }, + { + "@id": "https://w3id.org/workflowhub/workflow-ro-crate#galaxy", + "@type": "ComputerLanguage", + "identifier": { + "@id": "https://galaxyproject.org/" + }, + "name": "Galaxy", + "url": { + "@id": "https://galaxyproject.org/" + } + }, + { + "@id": "#test1", + "name": "test1", + "@type": "TestSuite", + "mainEntity": { + "@id": "sort-and-change-case.ga" + }, + "instance": [ + { + "@id": "#test1_1" + } + ], + "definition": { + "@id": "sort-and-change-case-tests.yml" + } + }, + { + "@id": "#test1_1", + "name": "test1_1", + "@type": "TestInstance", + "url": "http://example.org/jenkins", + "resource": "job/tests/" + }, + { + "@id": "sort-and-change-case-tests.yml", + "@type": [ + "File", + "TestDefinition" + ], + "conformsTo": { + "@id": "https://w3id.org/ro/terms/test#PlanemoEngine" + }, + "engineVersion": ">=0.70" + }, + { + "@id": "https://w3id.org/ro/terms/test#PlanemoEngine", + "@type": "SoftwareApplication", + "name": "Planemo", + "url": { + "@id": "https://github.com/galaxyproject/planemo" + } + } + ] +} diff --git a/tests/integration/profiles/workflow-testing-ro-crate/test_wtroc_testinstance.py b/tests/integration/profiles/workflow-testing-ro-crate/test_wtroc_testinstance.py new file mode 100644 index 0000000..f2cbf03 --- /dev/null +++ b/tests/integration/profiles/workflow-testing-ro-crate/test_wtroc_testinstance.py @@ -0,0 +1,37 @@ +# Copyright (c) 2024 CRS4 +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import logging + +from rocrate_validator.models import Severity +from tests.ro_crates import InvalidWTROC +from tests.shared import do_entity_test + +# set up logging +logger = logging.getLogger(__name__) + + +def test_wtroc_testinstance_no_service(): + """\ + Test a Workflow Testing RO-Crate where a TestInstance does not refer to + a TestService. + """ + do_entity_test( + InvalidWTROC().testinstance_no_service, + Severity.REQUIRED, + False, + ["Workflow Testing RO-Crate TestInstance MUST"], + ["The TestInstance MUST refer to a TestService via runsOn"], + profile_identifier="workflow-testing-ro-crate" + ) diff --git a/tests/ro_crates.py b/tests/ro_crates.py index a39477e..29d5117 100644 --- a/tests/ro_crates.py +++ b/tests/ro_crates.py @@ -484,3 +484,7 @@ def testsuite_no_instance_no_def(self) -> Path: @property def testsuite_no_mainentity(self) -> Path: return self.base_path / "testsuite_no_mainentity" + + @property + def testinstance_no_service(self) -> Path: + return self.base_path / "testinstance_no_service" From 99c0af60592ac0b35950791a5f232adbea5ab729 Mon Sep 17 00:00:00 2001 From: simleo Date: Thu, 19 Sep 2024 11:30:44 +0200 Subject: [PATCH 09/11] wtroc: more tests for test instance --- .../must/2_test_instance.ttl | 4 +- .../ro-crate-metadata.json | 132 ++++++++++++++++++ .../ro-crate-metadata.json | 132 ++++++++++++++++++ .../test_wtroc_testinstance.py | 30 ++++ tests/ro_crates.py | 8 ++ 5 files changed, 304 insertions(+), 2 deletions(-) create mode 100644 tests/data/crates/invalid/5_workflow_testing_ro_crate/testinstance_no_resource/ro-crate-metadata.json create mode 100644 tests/data/crates/invalid/5_workflow_testing_ro_crate/testinstance_no_url/ro-crate-metadata.json diff --git a/rocrate_validator/profiles/workflow-testing-ro-crate/must/2_test_instance.ttl b/rocrate_validator/profiles/workflow-testing-ro-crate/must/2_test_instance.ttl index 54565c5..6c31c7c 100644 --- a/rocrate_validator/profiles/workflow-testing-ro-crate/must/2_test_instance.ttl +++ b/rocrate_validator/profiles/workflow-testing-ro-crate/must/2_test_instance.ttl @@ -51,9 +51,9 @@ workflow-testing-ro-crate:WTROCTestInstanceRequired a sh:NodeShape ; ] ; sh:property [ a sh:PropertyShape ; sh:name "TestInstance resource" ; - sh:description "The TestInstance MUST refer to the relative URL of the test project base URL via resource" ; + sh:description "The TestInstance MUST refer to the relative URL of the test project via resource" ; sh:path wftest:resource ; sh:datatype xsd:string ; sh:minCount 1 ; - sh:message "The TestInstance MUST refer to the relative URL of the test project base URL via resource" ; + sh:message "The TestInstance MUST refer to the relative URL of the test project via resource" ; ] . diff --git a/tests/data/crates/invalid/5_workflow_testing_ro_crate/testinstance_no_resource/ro-crate-metadata.json b/tests/data/crates/invalid/5_workflow_testing_ro_crate/testinstance_no_resource/ro-crate-metadata.json new file mode 100644 index 0000000..80fae22 --- /dev/null +++ b/tests/data/crates/invalid/5_workflow_testing_ro_crate/testinstance_no_resource/ro-crate-metadata.json @@ -0,0 +1,132 @@ +{ + "@context": [ + "https://w3id.org/ro/crate/1.1/context", + "https://w3id.org/ro/terms/test" + ], + "@graph": [ + { + "@id": "ro-crate-metadata.json", + "@type": "CreativeWork", + "about": { + "@id": "./" + }, + "conformsTo": [ + { + "@id": "https://w3id.org/ro/crate/1.1" + }, + { + "@id": "https://w3id.org/workflowhub/workflow-ro-crate/1.0" + } + ] + }, + { + "@id": "./", + "@type": "Dataset", + "datePublished": "2024-09-17T11:09:44+00:00", + "hasPart": [ + { + "@id": "sort-and-change-case.ga" + }, + { + "@id": "sort-and-change-case-tests.yml" + } + ], + "license": { + "@id": "https://spdx.org/licenses/Apache-2.0.html" + }, + "mainEntity": { + "@id": "sort-and-change-case.ga" + }, + "mentions": [ + { + "@id": "#test1" + } + ] + }, + { + "@id": "https://spdx.org/licenses/Apache-2.0.html", + "@type": "CreativeWork", + "name": "Apache 2.0 license" + }, + { + "@id": "sort-and-change-case.ga", + "@type": [ + "File", + "SoftwareSourceCode", + "ComputationalWorkflow" + ], + "conformsTo": { + "@id": "https://bioschemas.org/profiles/ComputationalWorkflow/1.0-RELEASE" + }, + "description": "sort lines and change text to upper case", + "license": "https://spdx.org/licenses/MIT.html", + "name": "sort-and-change-case", + "programmingLanguage": { + "@id": "https://w3id.org/workflowhub/workflow-ro-crate#galaxy" + } + }, + { + "@id": "https://w3id.org/workflowhub/workflow-ro-crate#galaxy", + "@type": "ComputerLanguage", + "identifier": { + "@id": "https://galaxyproject.org/" + }, + "name": "Galaxy", + "url": { + "@id": "https://galaxyproject.org/" + } + }, + { + "@id": "#test1", + "name": "test1", + "@type": "TestSuite", + "mainEntity": { + "@id": "sort-and-change-case.ga" + }, + "instance": [ + { + "@id": "#test1_1" + } + ], + "definition": { + "@id": "sort-and-change-case-tests.yml" + } + }, + { + "@id": "#test1_1", + "name": "test1_1", + "@type": "TestInstance", + "runsOn": { + "@id": "https://w3id.org/ro/terms/test#JenkinsService" + }, + "url": "http://example.org/jenkins" + }, + { + "@id": "https://w3id.org/ro/terms/test#JenkinsService", + "@type": "TestService", + "name": "Jenkins", + "url": { + "@id": "https://www.jenkins.io" + } + }, + { + "@id": "sort-and-change-case-tests.yml", + "@type": [ + "File", + "TestDefinition" + ], + "conformsTo": { + "@id": "https://w3id.org/ro/terms/test#PlanemoEngine" + }, + "engineVersion": ">=0.70" + }, + { + "@id": "https://w3id.org/ro/terms/test#PlanemoEngine", + "@type": "SoftwareApplication", + "name": "Planemo", + "url": { + "@id": "https://github.com/galaxyproject/planemo" + } + } + ] +} diff --git a/tests/data/crates/invalid/5_workflow_testing_ro_crate/testinstance_no_url/ro-crate-metadata.json b/tests/data/crates/invalid/5_workflow_testing_ro_crate/testinstance_no_url/ro-crate-metadata.json new file mode 100644 index 0000000..f302958 --- /dev/null +++ b/tests/data/crates/invalid/5_workflow_testing_ro_crate/testinstance_no_url/ro-crate-metadata.json @@ -0,0 +1,132 @@ +{ + "@context": [ + "https://w3id.org/ro/crate/1.1/context", + "https://w3id.org/ro/terms/test" + ], + "@graph": [ + { + "@id": "ro-crate-metadata.json", + "@type": "CreativeWork", + "about": { + "@id": "./" + }, + "conformsTo": [ + { + "@id": "https://w3id.org/ro/crate/1.1" + }, + { + "@id": "https://w3id.org/workflowhub/workflow-ro-crate/1.0" + } + ] + }, + { + "@id": "./", + "@type": "Dataset", + "datePublished": "2024-09-17T11:09:44+00:00", + "hasPart": [ + { + "@id": "sort-and-change-case.ga" + }, + { + "@id": "sort-and-change-case-tests.yml" + } + ], + "license": { + "@id": "https://spdx.org/licenses/Apache-2.0.html" + }, + "mainEntity": { + "@id": "sort-and-change-case.ga" + }, + "mentions": [ + { + "@id": "#test1" + } + ] + }, + { + "@id": "https://spdx.org/licenses/Apache-2.0.html", + "@type": "CreativeWork", + "name": "Apache 2.0 license" + }, + { + "@id": "sort-and-change-case.ga", + "@type": [ + "File", + "SoftwareSourceCode", + "ComputationalWorkflow" + ], + "conformsTo": { + "@id": "https://bioschemas.org/profiles/ComputationalWorkflow/1.0-RELEASE" + }, + "description": "sort lines and change text to upper case", + "license": "https://spdx.org/licenses/MIT.html", + "name": "sort-and-change-case", + "programmingLanguage": { + "@id": "https://w3id.org/workflowhub/workflow-ro-crate#galaxy" + } + }, + { + "@id": "https://w3id.org/workflowhub/workflow-ro-crate#galaxy", + "@type": "ComputerLanguage", + "identifier": { + "@id": "https://galaxyproject.org/" + }, + "name": "Galaxy", + "url": { + "@id": "https://galaxyproject.org/" + } + }, + { + "@id": "#test1", + "name": "test1", + "@type": "TestSuite", + "mainEntity": { + "@id": "sort-and-change-case.ga" + }, + "instance": [ + { + "@id": "#test1_1" + } + ], + "definition": { + "@id": "sort-and-change-case-tests.yml" + } + }, + { + "@id": "#test1_1", + "name": "test1_1", + "@type": "TestInstance", + "runsOn": { + "@id": "https://w3id.org/ro/terms/test#JenkinsService" + }, + "resource": "job/tests/" + }, + { + "@id": "https://w3id.org/ro/terms/test#JenkinsService", + "@type": "TestService", + "name": "Jenkins", + "url": { + "@id": "https://www.jenkins.io" + } + }, + { + "@id": "sort-and-change-case-tests.yml", + "@type": [ + "File", + "TestDefinition" + ], + "conformsTo": { + "@id": "https://w3id.org/ro/terms/test#PlanemoEngine" + }, + "engineVersion": ">=0.70" + }, + { + "@id": "https://w3id.org/ro/terms/test#PlanemoEngine", + "@type": "SoftwareApplication", + "name": "Planemo", + "url": { + "@id": "https://github.com/galaxyproject/planemo" + } + } + ] +} diff --git a/tests/integration/profiles/workflow-testing-ro-crate/test_wtroc_testinstance.py b/tests/integration/profiles/workflow-testing-ro-crate/test_wtroc_testinstance.py index f2cbf03..6ec6c97 100644 --- a/tests/integration/profiles/workflow-testing-ro-crate/test_wtroc_testinstance.py +++ b/tests/integration/profiles/workflow-testing-ro-crate/test_wtroc_testinstance.py @@ -35,3 +35,33 @@ def test_wtroc_testinstance_no_service(): ["The TestInstance MUST refer to a TestService via runsOn"], profile_identifier="workflow-testing-ro-crate" ) + + +def test_wtroc_testinstance_no_url(): + """\ + Test a Workflow Testing RO-Crate where a TestInstance does not refer to + the test service base URL. + """ + do_entity_test( + InvalidWTROC().testinstance_no_url, + Severity.REQUIRED, + False, + ["Workflow Testing RO-Crate TestInstance MUST"], + ["The TestInstance MUST refer to the test service base URL via url"], + profile_identifier="workflow-testing-ro-crate" + ) + + +def test_wtroc_testinstance_no_resource(): + """\ + Test a Workflow Testing RO-Crate where a TestInstance does not refer to + the relative URL of the test project via resource. + """ + do_entity_test( + InvalidWTROC().testinstance_no_resource, + Severity.REQUIRED, + False, + ["Workflow Testing RO-Crate TestInstance MUST"], + ["The TestInstance MUST refer to the relative URL of the test project via resource"], + profile_identifier="workflow-testing-ro-crate" + ) diff --git a/tests/ro_crates.py b/tests/ro_crates.py index 29d5117..ac1c2b9 100644 --- a/tests/ro_crates.py +++ b/tests/ro_crates.py @@ -488,3 +488,11 @@ def testsuite_no_mainentity(self) -> Path: @property def testinstance_no_service(self) -> Path: return self.base_path / "testinstance_no_service" + + @property + def testinstance_no_url(self) -> Path: + return self.base_path / "testinstance_no_url" + + @property + def testinstance_no_resource(self) -> Path: + return self.base_path / "testinstance_no_resource" From 0e091cf03e495e49987d893f857ebf39dd7e960b Mon Sep 17 00:00:00 2001 From: simleo Date: Thu, 19 Sep 2024 14:35:54 +0200 Subject: [PATCH 10/11] wtroc: add test definition --- .../must/3_test_definition.ttl | 56 ++++++++ .../ro-crate-metadata.json | 130 +++++++++++++++++ .../ro-crate-metadata.json | 122 ++++++++++++++++ .../ro-crate-metadata.json | 132 ++++++++++++++++++ .../test_wtroc_testdefinition.py | 67 +++++++++ tests/ro_crates.py | 12 ++ 6 files changed, 519 insertions(+) create mode 100644 rocrate_validator/profiles/workflow-testing-ro-crate/must/3_test_definition.ttl create mode 100644 tests/data/crates/invalid/5_workflow_testing_ro_crate/testdefinition_bad_type/ro-crate-metadata.json create mode 100644 tests/data/crates/invalid/5_workflow_testing_ro_crate/testdefinition_no_engine/ro-crate-metadata.json create mode 100644 tests/data/crates/invalid/5_workflow_testing_ro_crate/testdefinition_no_engineversion/ro-crate-metadata.json create mode 100644 tests/integration/profiles/workflow-testing-ro-crate/test_wtroc_testdefinition.py diff --git a/rocrate_validator/profiles/workflow-testing-ro-crate/must/3_test_definition.ttl b/rocrate_validator/profiles/workflow-testing-ro-crate/must/3_test_definition.ttl new file mode 100644 index 0000000..1b9f4b8 --- /dev/null +++ b/rocrate_validator/profiles/workflow-testing-ro-crate/must/3_test_definition.ttl @@ -0,0 +1,56 @@ +# Copyright (c) 2024 CRS4 +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +@prefix ro: <./> . +@prefix ro-crate: . +@prefix rdf: . +@prefix xsd: . +@prefix dct: . +@prefix workflow-testing-ro-crate: . +@prefix schema: . +@prefix sh: . +@prefix wroc: . +@prefix wftest: . + +workflow-testing-ro-crate:WTROCTestDefinitionRequired a sh:NodeShape ; + sh:name "Workflow Testing RO-Crate TestDefinition MUST" ; + sh:description "Required properties of the Workflow Testing RO-Crate TestDefinition" ; + sh:targetClass wftest:TestDefinition ; + sh:property [ + a sh:PropertyShape ; + sh:name "TestDefinition type" ; + sh:description "The TestDefinition MUST have types TestDefinition and File" ; + sh:path rdf:type ; + sh:hasValue schema:MediaObject, wftest:TestDefinition ; + sh:minCount 1 ; + sh:message "The TestDefinition MUST have types TestDefinition and File" ; + ] ; + sh:property [ + a sh:PropertyShape ; + sh:name "TestDefinition conformsTo" ; + sh:description "The TestDefinition MUST refer to the test engine it is written for via conformsTo" ; + sh:path dct:conformsTo ; + sh:class schema:SoftwareApplication ; + sh:minCount 1 ; + sh:message "The TestDefinition MUST refer to the test engine it is written for via conformsTo" ; + ] ; + sh:property [ + a sh:PropertyShape ; + sh:name "TestDefinition engineVersion" ; + sh:description "The TestDefinition MUST refer to the test engine version via engineVersion" ; + sh:path wftest:engineVersion ; + sh:datatype xsd:string ; + sh:minCount 1 ; + sh:message "The TestDefinition MUST refer to the test engine version via engineVersion" ; + ] . diff --git a/tests/data/crates/invalid/5_workflow_testing_ro_crate/testdefinition_bad_type/ro-crate-metadata.json b/tests/data/crates/invalid/5_workflow_testing_ro_crate/testdefinition_bad_type/ro-crate-metadata.json new file mode 100644 index 0000000..daeb9e2 --- /dev/null +++ b/tests/data/crates/invalid/5_workflow_testing_ro_crate/testdefinition_bad_type/ro-crate-metadata.json @@ -0,0 +1,130 @@ +{ + "@context": [ + "https://w3id.org/ro/crate/1.1/context", + "https://w3id.org/ro/terms/test" + ], + "@graph": [ + { + "@id": "ro-crate-metadata.json", + "@type": "CreativeWork", + "about": { + "@id": "./" + }, + "conformsTo": [ + { + "@id": "https://w3id.org/ro/crate/1.1" + }, + { + "@id": "https://w3id.org/workflowhub/workflow-ro-crate/1.0" + } + ] + }, + { + "@id": "./", + "@type": "Dataset", + "datePublished": "2024-09-17T11:09:44+00:00", + "hasPart": [ + { + "@id": "sort-and-change-case.ga" + }, + { + "@id": "sort-and-change-case-tests.yml" + } + ], + "license": { + "@id": "https://spdx.org/licenses/Apache-2.0.html" + }, + "mainEntity": { + "@id": "sort-and-change-case.ga" + }, + "mentions": [ + { + "@id": "#test1" + } + ] + }, + { + "@id": "https://spdx.org/licenses/Apache-2.0.html", + "@type": "CreativeWork", + "name": "Apache 2.0 license" + }, + { + "@id": "sort-and-change-case.ga", + "@type": [ + "File", + "SoftwareSourceCode", + "ComputationalWorkflow" + ], + "conformsTo": { + "@id": "https://bioschemas.org/profiles/ComputationalWorkflow/1.0-RELEASE" + }, + "description": "sort lines and change text to upper case", + "license": "https://spdx.org/licenses/MIT.html", + "name": "sort-and-change-case", + "programmingLanguage": { + "@id": "https://w3id.org/workflowhub/workflow-ro-crate#galaxy" + } + }, + { + "@id": "https://w3id.org/workflowhub/workflow-ro-crate#galaxy", + "@type": "ComputerLanguage", + "identifier": { + "@id": "https://galaxyproject.org/" + }, + "name": "Galaxy", + "url": { + "@id": "https://galaxyproject.org/" + } + }, + { + "@id": "#test1", + "name": "test1", + "@type": "TestSuite", + "mainEntity": { + "@id": "sort-and-change-case.ga" + }, + "instance": [ + { + "@id": "#test1_1" + } + ], + "definition": { + "@id": "sort-and-change-case-tests.yml" + } + }, + { + "@id": "#test1_1", + "name": "test1_1", + "@type": "TestInstance", + "runsOn": { + "@id": "https://w3id.org/ro/terms/test#JenkinsService" + }, + "url": "http://example.org/jenkins", + "resource": "job/tests/" + }, + { + "@id": "https://w3id.org/ro/terms/test#JenkinsService", + "@type": "TestService", + "name": "Jenkins", + "url": { + "@id": "https://www.jenkins.io" + } + }, + { + "@id": "sort-and-change-case-tests.yml", + "@type": "TestDefinition", + "conformsTo": { + "@id": "https://w3id.org/ro/terms/test#PlanemoEngine" + }, + "engineVersion": ">=0.70" + }, + { + "@id": "https://w3id.org/ro/terms/test#PlanemoEngine", + "@type": "SoftwareApplication", + "name": "Planemo", + "url": { + "@id": "https://github.com/galaxyproject/planemo" + } + } + ] +} diff --git a/tests/data/crates/invalid/5_workflow_testing_ro_crate/testdefinition_no_engine/ro-crate-metadata.json b/tests/data/crates/invalid/5_workflow_testing_ro_crate/testdefinition_no_engine/ro-crate-metadata.json new file mode 100644 index 0000000..78ca9ef --- /dev/null +++ b/tests/data/crates/invalid/5_workflow_testing_ro_crate/testdefinition_no_engine/ro-crate-metadata.json @@ -0,0 +1,122 @@ +{ + "@context": [ + "https://w3id.org/ro/crate/1.1/context", + "https://w3id.org/ro/terms/test" + ], + "@graph": [ + { + "@id": "ro-crate-metadata.json", + "@type": "CreativeWork", + "about": { + "@id": "./" + }, + "conformsTo": [ + { + "@id": "https://w3id.org/ro/crate/1.1" + }, + { + "@id": "https://w3id.org/workflowhub/workflow-ro-crate/1.0" + } + ] + }, + { + "@id": "./", + "@type": "Dataset", + "datePublished": "2024-09-17T11:09:44+00:00", + "hasPart": [ + { + "@id": "sort-and-change-case.ga" + }, + { + "@id": "sort-and-change-case-tests.yml" + } + ], + "license": { + "@id": "https://spdx.org/licenses/Apache-2.0.html" + }, + "mainEntity": { + "@id": "sort-and-change-case.ga" + }, + "mentions": [ + { + "@id": "#test1" + } + ] + }, + { + "@id": "https://spdx.org/licenses/Apache-2.0.html", + "@type": "CreativeWork", + "name": "Apache 2.0 license" + }, + { + "@id": "sort-and-change-case.ga", + "@type": [ + "File", + "SoftwareSourceCode", + "ComputationalWorkflow" + ], + "conformsTo": { + "@id": "https://bioschemas.org/profiles/ComputationalWorkflow/1.0-RELEASE" + }, + "description": "sort lines and change text to upper case", + "license": "https://spdx.org/licenses/MIT.html", + "name": "sort-and-change-case", + "programmingLanguage": { + "@id": "https://w3id.org/workflowhub/workflow-ro-crate#galaxy" + } + }, + { + "@id": "https://w3id.org/workflowhub/workflow-ro-crate#galaxy", + "@type": "ComputerLanguage", + "identifier": { + "@id": "https://galaxyproject.org/" + }, + "name": "Galaxy", + "url": { + "@id": "https://galaxyproject.org/" + } + }, + { + "@id": "#test1", + "name": "test1", + "@type": "TestSuite", + "mainEntity": { + "@id": "sort-and-change-case.ga" + }, + "instance": [ + { + "@id": "#test1_1" + } + ], + "definition": { + "@id": "sort-and-change-case-tests.yml" + } + }, + { + "@id": "#test1_1", + "name": "test1_1", + "@type": "TestInstance", + "runsOn": { + "@id": "https://w3id.org/ro/terms/test#JenkinsService" + }, + "url": "http://example.org/jenkins", + "resource": "job/tests/" + }, + { + "@id": "https://w3id.org/ro/terms/test#JenkinsService", + "@type": "TestService", + "name": "Jenkins", + "url": { + "@id": "https://www.jenkins.io" + } + }, + { + "@id": "sort-and-change-case-tests.yml", + "@type": [ + "File", + "TestDefinition" + ], + "engineVersion": ">=0.70" + } + ] +} diff --git a/tests/data/crates/invalid/5_workflow_testing_ro_crate/testdefinition_no_engineversion/ro-crate-metadata.json b/tests/data/crates/invalid/5_workflow_testing_ro_crate/testdefinition_no_engineversion/ro-crate-metadata.json new file mode 100644 index 0000000..0742cea --- /dev/null +++ b/tests/data/crates/invalid/5_workflow_testing_ro_crate/testdefinition_no_engineversion/ro-crate-metadata.json @@ -0,0 +1,132 @@ +{ + "@context": [ + "https://w3id.org/ro/crate/1.1/context", + "https://w3id.org/ro/terms/test" + ], + "@graph": [ + { + "@id": "ro-crate-metadata.json", + "@type": "CreativeWork", + "about": { + "@id": "./" + }, + "conformsTo": [ + { + "@id": "https://w3id.org/ro/crate/1.1" + }, + { + "@id": "https://w3id.org/workflowhub/workflow-ro-crate/1.0" + } + ] + }, + { + "@id": "./", + "@type": "Dataset", + "datePublished": "2024-09-17T11:09:44+00:00", + "hasPart": [ + { + "@id": "sort-and-change-case.ga" + }, + { + "@id": "sort-and-change-case-tests.yml" + } + ], + "license": { + "@id": "https://spdx.org/licenses/Apache-2.0.html" + }, + "mainEntity": { + "@id": "sort-and-change-case.ga" + }, + "mentions": [ + { + "@id": "#test1" + } + ] + }, + { + "@id": "https://spdx.org/licenses/Apache-2.0.html", + "@type": "CreativeWork", + "name": "Apache 2.0 license" + }, + { + "@id": "sort-and-change-case.ga", + "@type": [ + "File", + "SoftwareSourceCode", + "ComputationalWorkflow" + ], + "conformsTo": { + "@id": "https://bioschemas.org/profiles/ComputationalWorkflow/1.0-RELEASE" + }, + "description": "sort lines and change text to upper case", + "license": "https://spdx.org/licenses/MIT.html", + "name": "sort-and-change-case", + "programmingLanguage": { + "@id": "https://w3id.org/workflowhub/workflow-ro-crate#galaxy" + } + }, + { + "@id": "https://w3id.org/workflowhub/workflow-ro-crate#galaxy", + "@type": "ComputerLanguage", + "identifier": { + "@id": "https://galaxyproject.org/" + }, + "name": "Galaxy", + "url": { + "@id": "https://galaxyproject.org/" + } + }, + { + "@id": "#test1", + "name": "test1", + "@type": "TestSuite", + "mainEntity": { + "@id": "sort-and-change-case.ga" + }, + "instance": [ + { + "@id": "#test1_1" + } + ], + "definition": { + "@id": "sort-and-change-case-tests.yml" + } + }, + { + "@id": "#test1_1", + "name": "test1_1", + "@type": "TestInstance", + "runsOn": { + "@id": "https://w3id.org/ro/terms/test#JenkinsService" + }, + "url": "http://example.org/jenkins", + "resource": "job/tests/" + }, + { + "@id": "https://w3id.org/ro/terms/test#JenkinsService", + "@type": "TestService", + "name": "Jenkins", + "url": { + "@id": "https://www.jenkins.io" + } + }, + { + "@id": "sort-and-change-case-tests.yml", + "@type": [ + "File", + "TestDefinition" + ], + "conformsTo": { + "@id": "https://w3id.org/ro/terms/test#PlanemoEngine" + } + }, + { + "@id": "https://w3id.org/ro/terms/test#PlanemoEngine", + "@type": "SoftwareApplication", + "name": "Planemo", + "url": { + "@id": "https://github.com/galaxyproject/planemo" + } + } + ] +} diff --git a/tests/integration/profiles/workflow-testing-ro-crate/test_wtroc_testdefinition.py b/tests/integration/profiles/workflow-testing-ro-crate/test_wtroc_testdefinition.py new file mode 100644 index 0000000..7e23d44 --- /dev/null +++ b/tests/integration/profiles/workflow-testing-ro-crate/test_wtroc_testdefinition.py @@ -0,0 +1,67 @@ +# Copyright (c) 2024 CRS4 +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import logging + +from rocrate_validator.models import Severity +from tests.ro_crates import InvalidWTROC +from tests.shared import do_entity_test + +# set up logging +logger = logging.getLogger(__name__) + + +def test_wtroc_testdefinition_bad_type(): + """\ + Test a Workflow Testing RO-Crate where a TestDefinition does not have the + File (MediaObject) and TestDefinition types. + """ + do_entity_test( + InvalidWTROC().testdefinition_bad_type, + Severity.REQUIRED, + False, + ["Workflow Testing RO-Crate TestDefinition MUST"], + ["The TestDefinition MUST have types TestDefinition and File"], + profile_identifier="workflow-testing-ro-crate" + ) + + +def test_wtroc_testdefinition_no_engine(): + """\ + Test a Workflow Testing RO-Crate where a TestDefinition does not refer + to the test engine SoftwareApplication via conformsTo. + """ + do_entity_test( + InvalidWTROC().testdefinition_no_engine, + Severity.REQUIRED, + False, + ["Workflow Testing RO-Crate TestDefinition MUST"], + ["The TestDefinition MUST refer to the test engine it is written for via conformsTo"], + profile_identifier="workflow-testing-ro-crate" + ) + + +def test_wtroc_testdefinition_no_engineversion(): + """\ + Test a Workflow Testing RO-Crate where a TestDefinition does not refer + to the test engine's version via engineVersion. + """ + do_entity_test( + InvalidWTROC().testdefinition_no_engineversion, + Severity.REQUIRED, + False, + ["Workflow Testing RO-Crate TestDefinition MUST"], + ["The TestDefinition MUST refer to the test engine version via engineVersion"], + profile_identifier="workflow-testing-ro-crate" + ) diff --git a/tests/ro_crates.py b/tests/ro_crates.py index ac1c2b9..809b72b 100644 --- a/tests/ro_crates.py +++ b/tests/ro_crates.py @@ -496,3 +496,15 @@ def testinstance_no_url(self) -> Path: @property def testinstance_no_resource(self) -> Path: return self.base_path / "testinstance_no_resource" + + @property + def testdefinition_bad_type(self) -> Path: + return self.base_path / "testdefinition_bad_type" + + @property + def testdefinition_no_engine(self) -> Path: + return self.base_path / "testdefinition_no_engine" + + @property + def testdefinition_no_engineversion(self) -> Path: + return self.base_path / "testdefinition_no_engineversion" From 2f7ab7b84a1b76f8cf584f9d5c42b684671abca0 Mon Sep 17 00:00:00 2001 From: simleo Date: Thu, 19 Sep 2024 16:40:38 +0200 Subject: [PATCH 11/11] wtroc: more tests --- .../ro-crate-metadata.json | 133 +++++++++++++++++ .../ro-crate-metadata.json | 135 ++++++++++++++++++ .../ro-crate-metadata.json | 135 ++++++++++++++++++ .../ro-crate-metadata.json | 125 ++++++++++++++++ .../ro-crate-metadata.json | 133 +++++++++++++++++ .../ro-crate-metadata.json | 91 ++++++++++++ .../ro-crate-metadata.json | 93 ++++++++++++ .../ro-crate-metadata.json | 133 +++++++++++++++++ .../test_wtroc_testdefinition.py | 30 ++++ .../test_wtroc_testinstance.py | 45 ++++++ .../test_wtroc_testsuite.py | 45 ++++++ tests/ro_crates.py | 32 +++++ 12 files changed, 1130 insertions(+) create mode 100644 tests/data/crates/invalid/5_workflow_testing_ro_crate/testdefinition_bad_conformsto/ro-crate-metadata.json create mode 100644 tests/data/crates/invalid/5_workflow_testing_ro_crate/testdefinition_bad_engineversion/ro-crate-metadata.json create mode 100644 tests/data/crates/invalid/5_workflow_testing_ro_crate/testinstance_bad_resource/ro-crate-metadata.json create mode 100644 tests/data/crates/invalid/5_workflow_testing_ro_crate/testinstance_bad_runson/ro-crate-metadata.json create mode 100644 tests/data/crates/invalid/5_workflow_testing_ro_crate/testinstance_bad_url/ro-crate-metadata.json create mode 100644 tests/data/crates/invalid/5_workflow_testing_ro_crate/testsuite_bad_definition/ro-crate-metadata.json create mode 100644 tests/data/crates/invalid/5_workflow_testing_ro_crate/testsuite_bad_instance/ro-crate-metadata.json create mode 100644 tests/data/crates/invalid/5_workflow_testing_ro_crate/testsuite_bad_mainentity/ro-crate-metadata.json diff --git a/tests/data/crates/invalid/5_workflow_testing_ro_crate/testdefinition_bad_conformsto/ro-crate-metadata.json b/tests/data/crates/invalid/5_workflow_testing_ro_crate/testdefinition_bad_conformsto/ro-crate-metadata.json new file mode 100644 index 0000000..8729185 --- /dev/null +++ b/tests/data/crates/invalid/5_workflow_testing_ro_crate/testdefinition_bad_conformsto/ro-crate-metadata.json @@ -0,0 +1,133 @@ +{ + "@context": [ + "https://w3id.org/ro/crate/1.1/context", + "https://w3id.org/ro/terms/test" + ], + "@graph": [ + { + "@id": "ro-crate-metadata.json", + "@type": "CreativeWork", + "about": { + "@id": "./" + }, + "conformsTo": [ + { + "@id": "https://w3id.org/ro/crate/1.1" + }, + { + "@id": "https://w3id.org/workflowhub/workflow-ro-crate/1.0" + } + ] + }, + { + "@id": "./", + "@type": "Dataset", + "datePublished": "2024-09-17T11:09:44+00:00", + "hasPart": [ + { + "@id": "sort-and-change-case.ga" + }, + { + "@id": "sort-and-change-case-tests.yml" + } + ], + "license": { + "@id": "https://spdx.org/licenses/Apache-2.0.html" + }, + "mainEntity": { + "@id": "sort-and-change-case.ga" + }, + "mentions": [ + { + "@id": "#test1" + } + ] + }, + { + "@id": "https://spdx.org/licenses/Apache-2.0.html", + "@type": "CreativeWork", + "name": "Apache 2.0 license" + }, + { + "@id": "sort-and-change-case.ga", + "@type": [ + "File", + "SoftwareSourceCode", + "ComputationalWorkflow" + ], + "conformsTo": { + "@id": "https://bioschemas.org/profiles/ComputationalWorkflow/1.0-RELEASE" + }, + "description": "sort lines and change text to upper case", + "license": "https://spdx.org/licenses/MIT.html", + "name": "sort-and-change-case", + "programmingLanguage": { + "@id": "https://w3id.org/workflowhub/workflow-ro-crate#galaxy" + } + }, + { + "@id": "https://w3id.org/workflowhub/workflow-ro-crate#galaxy", + "@type": "ComputerLanguage", + "identifier": { + "@id": "https://galaxyproject.org/" + }, + "name": "Galaxy", + "url": { + "@id": "https://galaxyproject.org/" + } + }, + { + "@id": "#test1", + "name": "test1", + "@type": "TestSuite", + "mainEntity": { + "@id": "sort-and-change-case.ga" + }, + "instance": [ + { + "@id": "#test1_1" + } + ], + "definition": { + "@id": "sort-and-change-case-tests.yml" + } + }, + { + "@id": "#test1_1", + "name": "test1_1", + "@type": "TestInstance", + "runsOn": { + "@id": "https://w3id.org/ro/terms/test#JenkinsService" + }, + "url": "http://example.org/jenkins", + "resource": "job/tests/" + }, + { + "@id": "https://w3id.org/ro/terms/test#JenkinsService", + "@type": "TestService", + "name": "Jenkins", + "url": { + "@id": "https://www.jenkins.io" + } + }, + { + "@id": "sort-and-change-case-tests.yml", + "@type": [ + "File", + "TestDefinition" + ], + "conformsTo": { + "@id": "https://spdx.org/licenses/Apache-2.0.html" + }, + "engineVersion": ">=0.70" + }, + { + "@id": "https://w3id.org/ro/terms/test#PlanemoEngine", + "@type": "SoftwareApplication", + "name": "Planemo", + "url": { + "@id": "https://github.com/galaxyproject/planemo" + } + } + ] +} diff --git a/tests/data/crates/invalid/5_workflow_testing_ro_crate/testdefinition_bad_engineversion/ro-crate-metadata.json b/tests/data/crates/invalid/5_workflow_testing_ro_crate/testdefinition_bad_engineversion/ro-crate-metadata.json new file mode 100644 index 0000000..1565570 --- /dev/null +++ b/tests/data/crates/invalid/5_workflow_testing_ro_crate/testdefinition_bad_engineversion/ro-crate-metadata.json @@ -0,0 +1,135 @@ +{ + "@context": [ + "https://w3id.org/ro/crate/1.1/context", + "https://w3id.org/ro/terms/test" + ], + "@graph": [ + { + "@id": "ro-crate-metadata.json", + "@type": "CreativeWork", + "about": { + "@id": "./" + }, + "conformsTo": [ + { + "@id": "https://w3id.org/ro/crate/1.1" + }, + { + "@id": "https://w3id.org/workflowhub/workflow-ro-crate/1.0" + } + ] + }, + { + "@id": "./", + "@type": "Dataset", + "datePublished": "2024-09-17T11:09:44+00:00", + "hasPart": [ + { + "@id": "sort-and-change-case.ga" + }, + { + "@id": "sort-and-change-case-tests.yml" + } + ], + "license": { + "@id": "https://spdx.org/licenses/Apache-2.0.html" + }, + "mainEntity": { + "@id": "sort-and-change-case.ga" + }, + "mentions": [ + { + "@id": "#test1" + } + ] + }, + { + "@id": "https://spdx.org/licenses/Apache-2.0.html", + "@type": "CreativeWork", + "name": "Apache 2.0 license" + }, + { + "@id": "sort-and-change-case.ga", + "@type": [ + "File", + "SoftwareSourceCode", + "ComputationalWorkflow" + ], + "conformsTo": { + "@id": "https://bioschemas.org/profiles/ComputationalWorkflow/1.0-RELEASE" + }, + "description": "sort lines and change text to upper case", + "license": "https://spdx.org/licenses/MIT.html", + "name": "sort-and-change-case", + "programmingLanguage": { + "@id": "https://w3id.org/workflowhub/workflow-ro-crate#galaxy" + } + }, + { + "@id": "https://w3id.org/workflowhub/workflow-ro-crate#galaxy", + "@type": "ComputerLanguage", + "identifier": { + "@id": "https://galaxyproject.org/" + }, + "name": "Galaxy", + "url": { + "@id": "https://galaxyproject.org/" + } + }, + { + "@id": "#test1", + "name": "test1", + "@type": "TestSuite", + "mainEntity": { + "@id": "sort-and-change-case.ga" + }, + "instance": [ + { + "@id": "#test1_1" + } + ], + "definition": { + "@id": "sort-and-change-case-tests.yml" + } + }, + { + "@id": "#test1_1", + "name": "test1_1", + "@type": "TestInstance", + "runsOn": { + "@id": "https://w3id.org/ro/terms/test#JenkinsService" + }, + "url": "http://example.org/jenkins", + "resource": "job/tests/" + }, + { + "@id": "https://w3id.org/ro/terms/test#JenkinsService", + "@type": "TestService", + "name": "Jenkins", + "url": { + "@id": "https://www.jenkins.io" + } + }, + { + "@id": "sort-and-change-case-tests.yml", + "@type": [ + "File", + "TestDefinition" + ], + "conformsTo": { + "@id": "https://w3id.org/ro/terms/test#PlanemoEngine" + }, + "engineVersion": { + "@id": "http://example.com/foobar" + } + }, + { + "@id": "https://w3id.org/ro/terms/test#PlanemoEngine", + "@type": "SoftwareApplication", + "name": "Planemo", + "url": { + "@id": "https://github.com/galaxyproject/planemo" + } + } + ] +} diff --git a/tests/data/crates/invalid/5_workflow_testing_ro_crate/testinstance_bad_resource/ro-crate-metadata.json b/tests/data/crates/invalid/5_workflow_testing_ro_crate/testinstance_bad_resource/ro-crate-metadata.json new file mode 100644 index 0000000..57530be --- /dev/null +++ b/tests/data/crates/invalid/5_workflow_testing_ro_crate/testinstance_bad_resource/ro-crate-metadata.json @@ -0,0 +1,135 @@ +{ + "@context": [ + "https://w3id.org/ro/crate/1.1/context", + "https://w3id.org/ro/terms/test" + ], + "@graph": [ + { + "@id": "ro-crate-metadata.json", + "@type": "CreativeWork", + "about": { + "@id": "./" + }, + "conformsTo": [ + { + "@id": "https://w3id.org/ro/crate/1.1" + }, + { + "@id": "https://w3id.org/workflowhub/workflow-ro-crate/1.0" + } + ] + }, + { + "@id": "./", + "@type": "Dataset", + "datePublished": "2024-09-17T11:09:44+00:00", + "hasPart": [ + { + "@id": "sort-and-change-case.ga" + }, + { + "@id": "sort-and-change-case-tests.yml" + } + ], + "license": { + "@id": "https://spdx.org/licenses/Apache-2.0.html" + }, + "mainEntity": { + "@id": "sort-and-change-case.ga" + }, + "mentions": [ + { + "@id": "#test1" + } + ] + }, + { + "@id": "https://spdx.org/licenses/Apache-2.0.html", + "@type": "CreativeWork", + "name": "Apache 2.0 license" + }, + { + "@id": "sort-and-change-case.ga", + "@type": [ + "File", + "SoftwareSourceCode", + "ComputationalWorkflow" + ], + "conformsTo": { + "@id": "https://bioschemas.org/profiles/ComputationalWorkflow/1.0-RELEASE" + }, + "description": "sort lines and change text to upper case", + "license": "https://spdx.org/licenses/MIT.html", + "name": "sort-and-change-case", + "programmingLanguage": { + "@id": "https://w3id.org/workflowhub/workflow-ro-crate#galaxy" + } + }, + { + "@id": "https://w3id.org/workflowhub/workflow-ro-crate#galaxy", + "@type": "ComputerLanguage", + "identifier": { + "@id": "https://galaxyproject.org/" + }, + "name": "Galaxy", + "url": { + "@id": "https://galaxyproject.org/" + } + }, + { + "@id": "#test1", + "name": "test1", + "@type": "TestSuite", + "mainEntity": { + "@id": "sort-and-change-case.ga" + }, + "instance": [ + { + "@id": "#test1_1" + } + ], + "definition": { + "@id": "sort-and-change-case-tests.yml" + } + }, + { + "@id": "#test1_1", + "name": "test1_1", + "@type": "TestInstance", + "runsOn": { + "@id": "https://w3id.org/ro/terms/test#JenkinsService" + }, + "url": "http://example.org/jenkins", + "resource": { + "@id": "https://spdx.org/licenses/Apache-2.0.html" + } + }, + { + "@id": "https://w3id.org/ro/terms/test#JenkinsService", + "@type": "TestService", + "name": "Jenkins", + "url": { + "@id": "https://www.jenkins.io" + } + }, + { + "@id": "sort-and-change-case-tests.yml", + "@type": [ + "File", + "TestDefinition" + ], + "conformsTo": { + "@id": "https://w3id.org/ro/terms/test#PlanemoEngine" + }, + "engineVersion": ">=0.70" + }, + { + "@id": "https://w3id.org/ro/terms/test#PlanemoEngine", + "@type": "SoftwareApplication", + "name": "Planemo", + "url": { + "@id": "https://github.com/galaxyproject/planemo" + } + } + ] +} diff --git a/tests/data/crates/invalid/5_workflow_testing_ro_crate/testinstance_bad_runson/ro-crate-metadata.json b/tests/data/crates/invalid/5_workflow_testing_ro_crate/testinstance_bad_runson/ro-crate-metadata.json new file mode 100644 index 0000000..1eb769f --- /dev/null +++ b/tests/data/crates/invalid/5_workflow_testing_ro_crate/testinstance_bad_runson/ro-crate-metadata.json @@ -0,0 +1,125 @@ +{ + "@context": [ + "https://w3id.org/ro/crate/1.1/context", + "https://w3id.org/ro/terms/test" + ], + "@graph": [ + { + "@id": "ro-crate-metadata.json", + "@type": "CreativeWork", + "about": { + "@id": "./" + }, + "conformsTo": [ + { + "@id": "https://w3id.org/ro/crate/1.1" + }, + { + "@id": "https://w3id.org/workflowhub/workflow-ro-crate/1.0" + } + ] + }, + { + "@id": "./", + "@type": "Dataset", + "datePublished": "2024-09-17T11:09:44+00:00", + "hasPart": [ + { + "@id": "sort-and-change-case.ga" + }, + { + "@id": "sort-and-change-case-tests.yml" + } + ], + "license": { + "@id": "https://spdx.org/licenses/Apache-2.0.html" + }, + "mainEntity": { + "@id": "sort-and-change-case.ga" + }, + "mentions": [ + { + "@id": "#test1" + } + ] + }, + { + "@id": "https://spdx.org/licenses/Apache-2.0.html", + "@type": "CreativeWork", + "name": "Apache 2.0 license" + }, + { + "@id": "sort-and-change-case.ga", + "@type": [ + "File", + "SoftwareSourceCode", + "ComputationalWorkflow" + ], + "conformsTo": { + "@id": "https://bioschemas.org/profiles/ComputationalWorkflow/1.0-RELEASE" + }, + "description": "sort lines and change text to upper case", + "license": "https://spdx.org/licenses/MIT.html", + "name": "sort-and-change-case", + "programmingLanguage": { + "@id": "https://w3id.org/workflowhub/workflow-ro-crate#galaxy" + } + }, + { + "@id": "https://w3id.org/workflowhub/workflow-ro-crate#galaxy", + "@type": "ComputerLanguage", + "identifier": { + "@id": "https://galaxyproject.org/" + }, + "name": "Galaxy", + "url": { + "@id": "https://galaxyproject.org/" + } + }, + { + "@id": "#test1", + "name": "test1", + "@type": "TestSuite", + "mainEntity": { + "@id": "sort-and-change-case.ga" + }, + "instance": [ + { + "@id": "#test1_1" + } + ], + "definition": { + "@id": "sort-and-change-case-tests.yml" + } + }, + { + "@id": "#test1_1", + "name": "test1_1", + "@type": "TestInstance", + "runsOn": { + "@id": "sort-and-change-case.ga" + }, + "url": "http://example.org/jenkins", + "resource": "job/tests/" + }, + { + "@id": "sort-and-change-case-tests.yml", + "@type": [ + "File", + "TestDefinition" + ], + "conformsTo": { + "@id": "https://w3id.org/ro/terms/test#PlanemoEngine" + }, + "engineVersion": ">=0.70" + }, + { + "@id": "https://w3id.org/ro/terms/test#PlanemoEngine", + "@type": "SoftwareApplication", + "name": "Planemo", + "url": { + "@id": "https://github.com/galaxyproject/planemo" + } + } + ] +} diff --git a/tests/data/crates/invalid/5_workflow_testing_ro_crate/testinstance_bad_url/ro-crate-metadata.json b/tests/data/crates/invalid/5_workflow_testing_ro_crate/testinstance_bad_url/ro-crate-metadata.json new file mode 100644 index 0000000..dc4fc7b --- /dev/null +++ b/tests/data/crates/invalid/5_workflow_testing_ro_crate/testinstance_bad_url/ro-crate-metadata.json @@ -0,0 +1,133 @@ +{ + "@context": [ + "https://w3id.org/ro/crate/1.1/context", + "https://w3id.org/ro/terms/test" + ], + "@graph": [ + { + "@id": "ro-crate-metadata.json", + "@type": "CreativeWork", + "about": { + "@id": "./" + }, + "conformsTo": [ + { + "@id": "https://w3id.org/ro/crate/1.1" + }, + { + "@id": "https://w3id.org/workflowhub/workflow-ro-crate/1.0" + } + ] + }, + { + "@id": "./", + "@type": "Dataset", + "datePublished": "2024-09-17T11:09:44+00:00", + "hasPart": [ + { + "@id": "sort-and-change-case.ga" + }, + { + "@id": "sort-and-change-case-tests.yml" + } + ], + "license": { + "@id": "https://spdx.org/licenses/Apache-2.0.html" + }, + "mainEntity": { + "@id": "sort-and-change-case.ga" + }, + "mentions": [ + { + "@id": "#test1" + } + ] + }, + { + "@id": "https://spdx.org/licenses/Apache-2.0.html", + "@type": "CreativeWork", + "name": "Apache 2.0 license" + }, + { + "@id": "sort-and-change-case.ga", + "@type": [ + "File", + "SoftwareSourceCode", + "ComputationalWorkflow" + ], + "conformsTo": { + "@id": "https://bioschemas.org/profiles/ComputationalWorkflow/1.0-RELEASE" + }, + "description": "sort lines and change text to upper case", + "license": "https://spdx.org/licenses/MIT.html", + "name": "sort-and-change-case", + "programmingLanguage": { + "@id": "https://w3id.org/workflowhub/workflow-ro-crate#galaxy" + } + }, + { + "@id": "https://w3id.org/workflowhub/workflow-ro-crate#galaxy", + "@type": "ComputerLanguage", + "identifier": { + "@id": "https://galaxyproject.org/" + }, + "name": "Galaxy", + "url": { + "@id": "https://galaxyproject.org/" + } + }, + { + "@id": "#test1", + "name": "test1", + "@type": "TestSuite", + "mainEntity": { + "@id": "sort-and-change-case.ga" + }, + "instance": [ + { + "@id": "#test1_1" + } + ], + "definition": { + "@id": "sort-and-change-case-tests.yml" + } + }, + { + "@id": "#test1_1", + "name": "test1_1", + "@type": "TestInstance", + "runsOn": { + "@id": "https://w3id.org/ro/terms/test#JenkinsService" + }, + "url": "foobar", + "resource": "job/tests/" + }, + { + "@id": "https://w3id.org/ro/terms/test#JenkinsService", + "@type": "TestService", + "name": "Jenkins", + "url": { + "@id": "https://www.jenkins.io" + } + }, + { + "@id": "sort-and-change-case-tests.yml", + "@type": [ + "File", + "TestDefinition" + ], + "conformsTo": { + "@id": "https://w3id.org/ro/terms/test#PlanemoEngine" + }, + "engineVersion": ">=0.70" + }, + { + "@id": "https://w3id.org/ro/terms/test#PlanemoEngine", + "@type": "SoftwareApplication", + "name": "Planemo", + "url": { + "@id": "https://github.com/galaxyproject/planemo" + } + } + ] +} diff --git a/tests/data/crates/invalid/5_workflow_testing_ro_crate/testsuite_bad_definition/ro-crate-metadata.json b/tests/data/crates/invalid/5_workflow_testing_ro_crate/testsuite_bad_definition/ro-crate-metadata.json new file mode 100644 index 0000000..be902fd --- /dev/null +++ b/tests/data/crates/invalid/5_workflow_testing_ro_crate/testsuite_bad_definition/ro-crate-metadata.json @@ -0,0 +1,91 @@ +{ + "@context": [ + "https://w3id.org/ro/crate/1.1/context", + "https://w3id.org/ro/terms/test" + ], + "@graph": [ + { + "@id": "ro-crate-metadata.json", + "@type": "CreativeWork", + "about": { + "@id": "./" + }, + "conformsTo": [ + { + "@id": "https://w3id.org/ro/crate/1.1" + }, + { + "@id": "https://w3id.org/workflowhub/workflow-ro-crate/1.0" + } + ] + }, + { + "@id": "./", + "@type": "Dataset", + "datePublished": "2024-09-17T11:09:44+00:00", + "hasPart": [ + { + "@id": "sort-and-change-case.ga" + }, + { + "@id": "sort-and-change-case-tests.yml" + } + ], + "license": { + "@id": "https://spdx.org/licenses/Apache-2.0.html" + }, + "mainEntity": { + "@id": "sort-and-change-case.ga" + }, + "mentions": [ + { + "@id": "#test1" + } + ] + }, + { + "@id": "https://spdx.org/licenses/Apache-2.0.html", + "@type": "CreativeWork", + "name": "Apache 2.0 license" + }, + { + "@id": "sort-and-change-case.ga", + "@type": [ + "File", + "SoftwareSourceCode", + "ComputationalWorkflow" + ], + "conformsTo": { + "@id": "https://bioschemas.org/profiles/ComputationalWorkflow/1.0-RELEASE" + }, + "description": "sort lines and change text to upper case", + "license": "https://spdx.org/licenses/MIT.html", + "name": "sort-and-change-case", + "programmingLanguage": { + "@id": "https://w3id.org/workflowhub/workflow-ro-crate#galaxy" + } + }, + { + "@id": "https://w3id.org/workflowhub/workflow-ro-crate#galaxy", + "@type": "ComputerLanguage", + "identifier": { + "@id": "https://galaxyproject.org/" + }, + "name": "Galaxy", + "url": { + "@id": "https://galaxyproject.org/" + } + }, + { + "@id": "#test1", + "name": "test1", + "@type": "TestSuite", + "mainEntity": { + "@id": "sort-and-change-case.ga" + }, + "definition": { + "@id": "sort-and-change-case.ga" + } + } + ] +} diff --git a/tests/data/crates/invalid/5_workflow_testing_ro_crate/testsuite_bad_instance/ro-crate-metadata.json b/tests/data/crates/invalid/5_workflow_testing_ro_crate/testsuite_bad_instance/ro-crate-metadata.json new file mode 100644 index 0000000..87ad51b --- /dev/null +++ b/tests/data/crates/invalid/5_workflow_testing_ro_crate/testsuite_bad_instance/ro-crate-metadata.json @@ -0,0 +1,93 @@ +{ + "@context": [ + "https://w3id.org/ro/crate/1.1/context", + "https://w3id.org/ro/terms/test" + ], + "@graph": [ + { + "@id": "ro-crate-metadata.json", + "@type": "CreativeWork", + "about": { + "@id": "./" + }, + "conformsTo": [ + { + "@id": "https://w3id.org/ro/crate/1.1" + }, + { + "@id": "https://w3id.org/workflowhub/workflow-ro-crate/1.0" + } + ] + }, + { + "@id": "./", + "@type": "Dataset", + "datePublished": "2024-09-17T11:09:44+00:00", + "hasPart": [ + { + "@id": "sort-and-change-case.ga" + }, + { + "@id": "sort-and-change-case-tests.yml" + } + ], + "license": { + "@id": "https://spdx.org/licenses/Apache-2.0.html" + }, + "mainEntity": { + "@id": "sort-and-change-case.ga" + }, + "mentions": [ + { + "@id": "#test1" + } + ] + }, + { + "@id": "https://spdx.org/licenses/Apache-2.0.html", + "@type": "CreativeWork", + "name": "Apache 2.0 license" + }, + { + "@id": "sort-and-change-case.ga", + "@type": [ + "File", + "SoftwareSourceCode", + "ComputationalWorkflow" + ], + "conformsTo": { + "@id": "https://bioschemas.org/profiles/ComputationalWorkflow/1.0-RELEASE" + }, + "description": "sort lines and change text to upper case", + "license": "https://spdx.org/licenses/MIT.html", + "name": "sort-and-change-case", + "programmingLanguage": { + "@id": "https://w3id.org/workflowhub/workflow-ro-crate#galaxy" + } + }, + { + "@id": "https://w3id.org/workflowhub/workflow-ro-crate#galaxy", + "@type": "ComputerLanguage", + "identifier": { + "@id": "https://galaxyproject.org/" + }, + "name": "Galaxy", + "url": { + "@id": "https://galaxyproject.org/" + } + }, + { + "@id": "#test1", + "name": "test1", + "@type": "TestSuite", + "mainEntity": { + "@id": "sort-and-change-case.ga" + }, + "instance": [ + { + "@id": "sort-and-change-case.ga" + } + ] + } + ] +} diff --git a/tests/data/crates/invalid/5_workflow_testing_ro_crate/testsuite_bad_mainentity/ro-crate-metadata.json b/tests/data/crates/invalid/5_workflow_testing_ro_crate/testsuite_bad_mainentity/ro-crate-metadata.json new file mode 100644 index 0000000..d29f7df --- /dev/null +++ b/tests/data/crates/invalid/5_workflow_testing_ro_crate/testsuite_bad_mainentity/ro-crate-metadata.json @@ -0,0 +1,133 @@ +{ + "@context": [ + "https://w3id.org/ro/crate/1.1/context", + "https://w3id.org/ro/terms/test" + ], + "@graph": [ + { + "@id": "ro-crate-metadata.json", + "@type": "CreativeWork", + "about": { + "@id": "./" + }, + "conformsTo": [ + { + "@id": "https://w3id.org/ro/crate/1.1" + }, + { + "@id": "https://w3id.org/workflowhub/workflow-ro-crate/1.0" + } + ] + }, + { + "@id": "./", + "@type": "Dataset", + "datePublished": "2024-09-17T11:09:44+00:00", + "hasPart": [ + { + "@id": "sort-and-change-case.ga" + }, + { + "@id": "sort-and-change-case-tests.yml" + } + ], + "license": { + "@id": "https://spdx.org/licenses/Apache-2.0.html" + }, + "mainEntity": { + "@id": "sort-and-change-case.ga" + }, + "mentions": [ + { + "@id": "#test1" + } + ] + }, + { + "@id": "https://spdx.org/licenses/Apache-2.0.html", + "@type": "CreativeWork", + "name": "Apache 2.0 license" + }, + { + "@id": "sort-and-change-case.ga", + "@type": [ + "File", + "SoftwareSourceCode", + "ComputationalWorkflow" + ], + "conformsTo": { + "@id": "https://bioschemas.org/profiles/ComputationalWorkflow/1.0-RELEASE" + }, + "description": "sort lines and change text to upper case", + "license": "https://spdx.org/licenses/MIT.html", + "name": "sort-and-change-case", + "programmingLanguage": { + "@id": "https://w3id.org/workflowhub/workflow-ro-crate#galaxy" + } + }, + { + "@id": "https://w3id.org/workflowhub/workflow-ro-crate#galaxy", + "@type": "ComputerLanguage", + "identifier": { + "@id": "https://galaxyproject.org/" + }, + "name": "Galaxy", + "url": { + "@id": "https://galaxyproject.org/" + } + }, + { + "@id": "#test1", + "name": "test1", + "@type": "TestSuite", + "mainEntity": { + "@id": "https://spdx.org/licenses/Apache-2.0.html" + }, + "instance": [ + { + "@id": "#test1_1" + } + ], + "definition": { + "@id": "sort-and-change-case-tests.yml" + } + }, + { + "@id": "#test1_1", + "name": "test1_1", + "@type": "TestInstance", + "runsOn": { + "@id": "https://w3id.org/ro/terms/test#JenkinsService" + }, + "url": "http://example.org/jenkins", + "resource": "job/tests/" + }, + { + "@id": "https://w3id.org/ro/terms/test#JenkinsService", + "@type": "TestService", + "name": "Jenkins", + "url": { + "@id": "https://www.jenkins.io" + } + }, + { + "@id": "sort-and-change-case-tests.yml", + "@type": [ + "File", + "TestDefinition" + ], + "conformsTo": { + "@id": "https://w3id.org/ro/terms/test#PlanemoEngine" + }, + "engineVersion": ">=0.70" + }, + { + "@id": "https://w3id.org/ro/terms/test#PlanemoEngine", + "@type": "SoftwareApplication", + "name": "Planemo", + "url": { + "@id": "https://github.com/galaxyproject/planemo" + } + } + ] +} diff --git a/tests/integration/profiles/workflow-testing-ro-crate/test_wtroc_testdefinition.py b/tests/integration/profiles/workflow-testing-ro-crate/test_wtroc_testdefinition.py index 7e23d44..f7f35ca 100644 --- a/tests/integration/profiles/workflow-testing-ro-crate/test_wtroc_testdefinition.py +++ b/tests/integration/profiles/workflow-testing-ro-crate/test_wtroc_testdefinition.py @@ -65,3 +65,33 @@ def test_wtroc_testdefinition_no_engineversion(): ["The TestDefinition MUST refer to the test engine version via engineVersion"], profile_identifier="workflow-testing-ro-crate" ) + + +def test_wtroc_testdefinition_bad_conformsto(): + """\ + Test a Workflow Testing RO-Crate where a TestDefinition does not refer + to the test engine SoftwareApplication via conformsTo. + """ + do_entity_test( + InvalidWTROC().testdefinition_bad_conformsto, + Severity.REQUIRED, + False, + ["Workflow Testing RO-Crate TestDefinition MUST"], + ["The TestDefinition MUST refer to the test engine it is written for via conformsTo"], + profile_identifier="workflow-testing-ro-crate" + ) + + +def test_wtroc_testdefinition_bad_engineversion(): + """\ + Test a Workflow Testing RO-Crate where a TestDefinition does not refer + to the test engine's version as a string. + """ + do_entity_test( + InvalidWTROC().testdefinition_bad_engineversion, + Severity.REQUIRED, + False, + ["Workflow Testing RO-Crate TestDefinition MUST"], + ["The TestDefinition MUST refer to the test engine version via engineVersion"], + profile_identifier="workflow-testing-ro-crate" + ) diff --git a/tests/integration/profiles/workflow-testing-ro-crate/test_wtroc_testinstance.py b/tests/integration/profiles/workflow-testing-ro-crate/test_wtroc_testinstance.py index 6ec6c97..f90aa9a 100644 --- a/tests/integration/profiles/workflow-testing-ro-crate/test_wtroc_testinstance.py +++ b/tests/integration/profiles/workflow-testing-ro-crate/test_wtroc_testinstance.py @@ -65,3 +65,48 @@ def test_wtroc_testinstance_no_resource(): ["The TestInstance MUST refer to the relative URL of the test project via resource"], profile_identifier="workflow-testing-ro-crate" ) + + +def test_wtroc_testinstance_bad_runson(): + """\ + Test a Workflow Testing RO-Crate where a TestInstance has a runsOn + property that does not refer to a TestService. + """ + do_entity_test( + InvalidWTROC().testinstance_bad_runson, + Severity.REQUIRED, + False, + ["Workflow Testing RO-Crate TestInstance MUST"], + ["The TestInstance MUST refer to a TestService via runsOn"], + profile_identifier="workflow-testing-ro-crate" + ) + + +def test_wtroc_testinstance_bad_url(): + """\ + Test a Workflow Testing RO-Crate where a TestInstance has a url + property that does not refer to a string with a URL pattern. + """ + do_entity_test( + InvalidWTROC().testinstance_bad_url, + Severity.REQUIRED, + False, + ["Workflow Testing RO-Crate TestInstance MUST"], + ["The TestInstance MUST refer to the test service base URL via url"], + profile_identifier="workflow-testing-ro-crate" + ) + + +def test_wtroc_testinstance_bad_resource(): + """\ + Test a Workflow Testing RO-Crate where a TestInstance has a resource + property that does not refer to a string. + """ + do_entity_test( + InvalidWTROC().testinstance_bad_resource, + Severity.REQUIRED, + False, + ["Workflow Testing RO-Crate TestInstance MUST"], + ["The TestInstance MUST refer to the relative URL of the test project via resource"], + profile_identifier="workflow-testing-ro-crate" + ) diff --git a/tests/integration/profiles/workflow-testing-ro-crate/test_wtroc_testsuite.py b/tests/integration/profiles/workflow-testing-ro-crate/test_wtroc_testsuite.py index ff673d9..bb42070 100644 --- a/tests/integration/profiles/workflow-testing-ro-crate/test_wtroc_testsuite.py +++ b/tests/integration/profiles/workflow-testing-ro-crate/test_wtroc_testsuite.py @@ -65,3 +65,48 @@ def test_wtroc_testsuite_no_mainentity(): ["The TestSuite SHOULD refer to the tested workflow via mainEntity"], profile_identifier="workflow-testing-ro-crate" ) + + +def test_wtroc_testsuite_bad_instance(): + """\ + Test a Workflow Testing RO-Crate where a TestSuite has an instance + property that does not refer to a TestInstance. + """ + do_entity_test( + InvalidWTROC().testsuite_bad_instance, + Severity.REQUIRED, + False, + ["TestSuite instance or definition"], + ["The TestSuite MUST refer to a TestInstance or TestDefinition"], + profile_identifier="workflow-testing-ro-crate" + ) + + +def test_wtroc_testsuite_bad_definition(): + """\ + Test a Workflow Testing RO-Crate where a TestSuite has a definition + property that does not refer to a TestDefinition. + """ + do_entity_test( + InvalidWTROC().testsuite_bad_definition, + Severity.REQUIRED, + False, + ["TestSuite instance or definition"], + ["The TestSuite MUST refer to a TestInstance or TestDefinition"], + profile_identifier="workflow-testing-ro-crate" + ) + + +def test_wtroc_testsuite_bad_mainentity(): + """\ + Test a Workflow Testing RO-Crate where a TestSuite has a mainEntity + property that does not refer to a workflow. + """ + do_entity_test( + InvalidWTROC().testsuite_bad_mainentity, + Severity.RECOMMENDED, + False, + ["Workflow Testing RO-Crate TestSuite SHOULD"], + ["The TestSuite SHOULD refer to the tested workflow via mainEntity"], + profile_identifier="workflow-testing-ro-crate" + ) diff --git a/tests/ro_crates.py b/tests/ro_crates.py index 809b72b..66ae548 100644 --- a/tests/ro_crates.py +++ b/tests/ro_crates.py @@ -508,3 +508,35 @@ def testdefinition_no_engine(self) -> Path: @property def testdefinition_no_engineversion(self) -> Path: return self.base_path / "testdefinition_no_engineversion" + + @property + def testsuite_bad_instance(self) -> Path: + return self.base_path / "testsuite_bad_instance" + + @property + def testsuite_bad_definition(self) -> Path: + return self.base_path / "testsuite_bad_definition" + + @property + def testsuite_bad_mainentity(self) -> Path: + return self.base_path / "testsuite_bad_mainentity" + + @property + def testinstance_bad_runson(self) -> Path: + return self.base_path / "testinstance_bad_runson" + + @property + def testinstance_bad_url(self) -> Path: + return self.base_path / "testinstance_bad_url" + + @property + def testinstance_bad_resource(self) -> Path: + return self.base_path / "testinstance_bad_resource" + + @property + def testdefinition_bad_conformsto(self) -> Path: + return self.base_path / "testdefinition_bad_conformsto" + + @property + def testdefinition_bad_engineversion(self) -> Path: + return self.base_path / "testdefinition_bad_engineversion"