Skip to content

Commit 1568ef6

Browse files
committed
Added tests for objects with ISA types that are not connected to ISA part of the crate
1 parent 3ff4245 commit 1568ef6

8 files changed

Lines changed: 305 additions & 77 deletions

File tree

tests/integration/profiles/isa-ro-crate/test_10_definedterm.py

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ def test_isa_defined_term_name():
3131
sparql = (
3232
SPARQL_PREFIXES
3333
+ """
34+
PREFIX bioschemas: <https://bioschemas.org/>
35+
PREFIX bioschemas-prop: <https://bioschemas.org/properties/>
3436
DELETE {
3537
?defined_term schema:name ?name .
3638
}
@@ -146,3 +148,47 @@ def test_isa_defined_term_termCode_of_incorrect_type():
146148
profile_identifier="isa-ro-crate",
147149
rocrate_entity_mod_sparql=sparql,
148150
)
151+
152+
153+
def test_isa_term_not_correctly_referenced():
154+
"""
155+
Test an ISA RO-Crate where an invalid defined term is not correctly referenced.
156+
Such defined terms should be ignored, meaning the validation should pass.
157+
"""
158+
sparql = (
159+
SPARQL_PREFIXES
160+
+ """
161+
PREFIX bioschemas: <https://bioschemas.org/>
162+
PREFIX bioschemas-prop: <https://bioschemas.org/properties/>
163+
DELETE {
164+
?protocol bioschemas-prop:intendedUse ?term .
165+
?person schema:jobTitle ?term .
166+
?assay schema:measurementTechnique ?term .
167+
?assay schema:measurementMethod ?term .
168+
?term schema:name ?name .
169+
}
170+
INSERT {
171+
?assay schema:mentions ?term .
172+
}
173+
WHERE {
174+
?protocol a bioschemas:LabProtocol .
175+
?person a schema:Person .
176+
?assay a schema:Dataset .
177+
?term a schema:DefinedTerm .
178+
?term schema:name ?name .
179+
?protocol bioschemas-prop:intendedUse ?term .
180+
?person schema:jobTitle ?term .
181+
?assay schema:measurementTechnique ?term .
182+
?assay schema:measurementMethod ?term .
183+
}
184+
"""
185+
)
186+
187+
do_entity_test(
188+
rocrate_path=ValidROC().isa_ro_crate,
189+
requirement_severity=Severity.REQUIRED,
190+
expected_validation_result=True,
191+
profile_identifier="isa-ro-crate",
192+
rocrate_entity_mod_sparql=sparql,
193+
disable_inherited_profiles_issue_reporting=True,
194+
)

tests/integration/profiles/isa-ro-crate/test_3_process.py

Lines changed: 40 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -56,46 +56,46 @@ def test_isa_process_name():
5656
)
5757

5858

59-
# def test_isa_process_not_correctly_referenced_from_dataset():
60-
# """
61-
# Test an ISA RO-Crate where an invalid Process is referenced from a Dataset with wrong property.
62-
# Such processes should be ignored, meaning the validation should pass.
63-
# """
64-
# sparql = (
65-
# SPARQL_PREFIXES
66-
# + """
67-
# PREFIX schema: <http://schema.org/>
68-
# PREFIX bioschemas: <https://bioschemas.org/>
69-
# PREFIX bioschemas-prop: <https://bioschemas.org/properties/>
70-
# DELETE {
71-
# ?dataset schema:about ?process .
72-
# ?process schema:name ?name .
73-
# }
74-
# INSERT {
75-
# ?dataset schema:mentions ?process .
76-
# }
77-
# WHERE {
78-
# ?dataset a schema:Dataset .
79-
# ?dataset schema:about ?process.
80-
# ?process schema:name ?name .
81-
# }
82-
# """
83-
# )
84-
85-
# do_entity_test(
86-
# rocrate_path=ValidROC().isa_ro_crate,
87-
# requirement_severity=Severity.REQUIRED,
88-
# expected_validation_result=True,
89-
# # expected_triggered_requirements=[
90-
# # "Process MUST be directly referenced from a dataset"
91-
# # ],
92-
# # expected_triggered_issues=[
93-
# # "Process MUST be directly referenced in about on a Dataset"
94-
# # ],
95-
# profile_identifier="isa-ro-crate",
96-
# rocrate_entity_mod_sparql=sparql,
97-
# skip_checks=[SKIP_LOCAL_DATA_ENTITY_EXISTENCE_CHECK_IDENTIFIER],
98-
# )
59+
def test_isa_process_not_correctly_referenced_from_dataset():
60+
"""
61+
Test an ISA RO-Crate where an invalid Process is not correctly referenced.
62+
Such processes should be ignored, meaning the validation should pass.
63+
"""
64+
sparql = (
65+
SPARQL_PREFIXES
66+
+ """
67+
PREFIX schema: <http://schema.org/>
68+
PREFIX bioschemas: <https://bioschemas.org/>
69+
PREFIX bioschemas-prop: <https://bioschemas.org/properties/>
70+
DELETE {
71+
?dataset schema:about ?process .
72+
?process schema:name ?name .
73+
}
74+
INSERT {
75+
?dataset schema:mentions ?process .
76+
}
77+
WHERE {
78+
?dataset a schema:Dataset .
79+
?dataset schema:about ?process.
80+
?process schema:name ?name .
81+
}
82+
"""
83+
)
84+
85+
do_entity_test(
86+
rocrate_path=ValidROC().isa_ro_crate,
87+
requirement_severity=Severity.REQUIRED,
88+
expected_validation_result=True,
89+
# expected_triggered_requirements=[
90+
# "Process MUST be directly referenced from a dataset"
91+
# ],
92+
# expected_triggered_issues=[
93+
# "Process MUST be directly referenced in about on a Dataset"
94+
# ],
95+
profile_identifier="isa-ro-crate",
96+
rocrate_entity_mod_sparql=sparql,
97+
disable_inherited_profiles_issue_reporting=True,
98+
)
9999

100100

101101
def test_isa_process_no_object():

tests/integration/profiles/isa-ro-crate/test_4_protocol.py

Lines changed: 37 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -183,44 +183,44 @@ def test_isa_protocol_no_intendedUse():
183183
rocrate_entity_mod_sparql=sparql,
184184
)
185185

186-
# def test_isa_protocol_not_correctly_referenced_from_process():
187-
# """
188-
# Test an ISA RO-Crate where an invalid Protocol is referenced from a process with wrong property.
189-
# Such protocols should be ignored, meaning the validation should pass.
190-
# """
191-
# sparql = (
192-
# SPARQL_PREFIXES
193-
# + """
194-
# PREFIX bioschemas: <https://bioschemas.org/>
195-
# PREFIX bioschemas-prop: <https://bioschemas.org/properties/>
196-
# DELETE {
197-
# ?process bioschemas-prop:executesProtocol ?protocol .
198-
# ?protocol schema:name ?name .
199-
# }
200-
# INSERT {
201-
# ?dataset schema:mentions ?protocol .
202-
# }
203-
# WHERE {
204-
# ?dataset a schema:Dataset .
205-
# ?dataset schema:additionalType "Assay" .
206-
# ?process a bioschemas:LabProcess .
207-
# ?protocol a bioschemas:LabProtocol .
208-
# ?process bioschemas-prop:executesProtocol ?protocol .
209-
# ?protocol schema:name ?name .
210-
# }
211-
# """
212-
# )
213186

214-
# do_entity_test(
215-
# rocrate_path=ValidROC().isa_ro_crate,
216-
# requirement_severity=Severity.RECOMMENDED,
217-
# expected_validation_result=True,
218-
# # expected_triggered_requirements=["Protocol SHOULD have intended use"],
219-
# # expected_triggered_issues=["Protocol intended use MUST be of type string or DefinedTerm"],
220-
# profile_identifier="isa-ro-crate",
221-
# rocrate_entity_mod_sparql=sparql,
222-
# skip_checks=[SKIP_LOCAL_DATA_ENTITY_EXISTENCE_CHECK_IDENTIFIER],
223-
# )
187+
def test_isa_protocol_not_correctly_referenced_from_process():
188+
"""
189+
Test an ISA RO-Crate where an invalid Protocol is not correctly referenced.
190+
Such protocols should be ignored, meaning the validation should pass.
191+
"""
192+
sparql = (
193+
SPARQL_PREFIXES
194+
+ """
195+
PREFIX bioschemas: <https://bioschemas.org/>
196+
PREFIX bioschemas-prop: <https://bioschemas.org/properties/>
197+
DELETE {
198+
?process bioschemas-prop:executesLabProtocol ?protocol .
199+
?protocol schema:description ?description .
200+
}
201+
INSERT {
202+
?process schema:mentions ?protocol .
203+
?protocol schema:description 42 .
204+
}
205+
WHERE {
206+
?process a bioschemas:LabProcess .
207+
?protocol a bioschemas:LabProtocol .
208+
?process bioschemas-prop:executesLabProtocol ?protocol .
209+
?protocol schema:description ?description .
210+
}
211+
"""
212+
)
213+
214+
do_entity_test(
215+
rocrate_path=ValidROC().isa_ro_crate,
216+
requirement_severity=Severity.REQUIRED,
217+
expected_validation_result=True,
218+
# expected_triggered_requirements=["Protocol SHOULD have intended use"],
219+
# expected_triggered_issues=["Protocol intended use MUST be of type string or DefinedTerm"],
220+
profile_identifier="isa-ro-crate",
221+
rocrate_entity_mod_sparql=sparql,
222+
disable_inherited_profiles_issue_reporting=True,
223+
)
224224

225225

226226
def test_isa_protocol_intendedUse_incorrect_type():

tests/integration/profiles/isa-ro-crate/test_5_sample.py

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,42 @@ def test_isa_sample_name():
5555
)
5656

5757

58+
def test_isa_sample_not_correctly_referenced_from_process():
59+
"""
60+
Test an ISA RO-Crate where an invalid Sample is not correctly referenced.
61+
Such samples should be ignored, meaning the validation should pass.
62+
"""
63+
sparql = (
64+
SPARQL_PREFIXES
65+
+ """
66+
PREFIX bioschemas: <https://bioschemas.org/>
67+
PREFIX bioschemas-prop: <https://bioschemas.org/properties/>
68+
DELETE {
69+
?process schema:object ?sample .
70+
?sample schema:name ?name .
71+
}
72+
INSERT {
73+
?process schema:mentions ?sample .
74+
}
75+
WHERE {
76+
?process a bioschemas:LabProcess .
77+
?sample a bioschemas:Sample .
78+
?process schema:object ?sample .
79+
?sample schema:name ?name .
80+
}
81+
"""
82+
)
83+
84+
do_entity_test(
85+
rocrate_path=ValidROC().isa_ro_crate,
86+
requirement_severity=Severity.REQUIRED,
87+
expected_validation_result=True,
88+
profile_identifier="isa-ro-crate",
89+
rocrate_entity_mod_sparql=sparql,
90+
disable_inherited_profiles_issue_reporting=True,
91+
)
92+
93+
5894
def test_isa_sample_name_of_incorrect_type():
5995
"""
6096
Test an ISA RO-Crate where a sample name has wrong type.

tests/integration/profiles/isa-ro-crate/test_6_data.py

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,42 @@ def test_isa_file_name():
5454
)
5555

5656

57+
def test_isa_data_not_correctly_referenced_from_process():
58+
"""
59+
Test an ISA RO-Crate where an invalid data file is not correctly referenced.
60+
Such files should be ignored, meaning the validation should pass.
61+
"""
62+
sparql = (
63+
SPARQL_PREFIXES
64+
+ """
65+
PREFIX bioschemas: <https://bioschemas.org/>
66+
PREFIX bioschemas-prop: <https://bioschemas.org/properties/>
67+
DELETE {
68+
?dataset schema:hasPart ?file .
69+
?file schema:name ?name .
70+
}
71+
INSERT {
72+
?dataset schema:mentions ?file .
73+
}
74+
WHERE {
75+
?dataset a schema:Dataset .
76+
?file a schema:MediaObject .
77+
?dataset schema:hasPart ?file .
78+
?file schema:name ?name .
79+
}
80+
"""
81+
)
82+
83+
do_entity_test(
84+
rocrate_path=ValidROC().isa_ro_crate,
85+
requirement_severity=Severity.REQUIRED,
86+
expected_validation_result=True,
87+
profile_identifier="isa-ro-crate",
88+
rocrate_entity_mod_sparql=sparql,
89+
disable_inherited_profiles_issue_reporting=True,
90+
)
91+
92+
5793
def test_isa_file_name_of_incorrect_type():
5894
"""
5995
Test an ISA RO-Crate where a file name has wrong type.

tests/integration/profiles/isa-ro-crate/test_7_person.py

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,45 @@ def test_isa_person_given_name():
5454
)
5555

5656

57+
def test_isa_person_not_correctly_referenced():
58+
"""
59+
Test an ISA RO-Crate where an invalid person is not correctly referenced.
60+
Such persons should be ignored, meaning the validation should pass.
61+
"""
62+
sparql = (
63+
SPARQL_PREFIXES
64+
+ """
65+
PREFIX bioschemas: <https://bioschemas.org/>
66+
PREFIX bioschemas-prop: <https://bioschemas.org/properties/>
67+
DELETE {
68+
?dataset schema:creator ?person .
69+
?person schema:givenName ?name .
70+
?article schema:author ?person .
71+
}
72+
INSERT {
73+
?dataset schema:mentions ?person .
74+
}
75+
WHERE {
76+
?dataset a schema:Dataset .
77+
?person a schema:Person .
78+
?article a schema:ScholarlyArticle .
79+
?article schema:author ?person .
80+
?dataset schema:creator ?person .
81+
?person schema:givenName ?name .
82+
}
83+
"""
84+
)
85+
86+
do_entity_test(
87+
rocrate_path=ValidROC().isa_ro_crate,
88+
requirement_severity=Severity.REQUIRED,
89+
expected_validation_result=True,
90+
profile_identifier="isa-ro-crate",
91+
rocrate_entity_mod_sparql=sparql,
92+
disable_inherited_profiles_issue_reporting=True,
93+
)
94+
95+
5796
def test_isa_person_given_name_of_incorrect_type():
5897
"""
5998
Test an ISA RO-Crate where a person given name has wrong type.

0 commit comments

Comments
 (0)