1414# limitations under the License.
1515
1616import logging
17+ import pytest
1718
19+ from rocrate_validator import services
1820from rocrate_validator .models import Severity
1921from tests .conftest import SKIP_LOCAL_DATA_ENTITY_EXISTENCE_CHECK_IDENTIFIER
2022from tests .ro_crates import ValidROC
2325logger = logging .getLogger (__name__ )
2426logger .setLevel (logging .DEBUG )
2527
28+ # Dynamically fetch the SKIP_WEB_RESOURCE_AVAILABILITY_IDENTIFIER
29+ # required as disable_inherited_profiles_reporting does not disable Python checks from
30+ # inherited profiles (https://github.com/crs4/rocrate-validator/issues/135)
31+ rocrate_profile = services .get_profile ("ro-crate" )
32+ if not rocrate_profile :
33+ raise RuntimeError ("Unable to load the RO-Crate profile" )
34+ check_local_data_entity_existence = rocrate_profile .get_requirement_check (
35+ "Web-based Data Entity: resource availability"
36+ )
37+ assert (
38+ check_local_data_entity_existence
39+ ), "Unable to find the requirement 'Web-based Data Entity: resource availability'"
40+ SKIP_WEB_RESOURCE_AVAILABILITY_IDENTIFIER = check_local_data_entity_existence .identifier
41+
2642
2743def test_valid_five_safes_crate_request_required ():
2844 """Test a valid Five Safes Crate representing a request."""
@@ -37,6 +53,27 @@ def test_valid_five_safes_crate_request_required():
3753 )
3854
3955
56+ @pytest .mark .xfail (
57+ reason = """
58+ Checks that ensure certain Five Safes actions are present currently fail for this crate,
59+ as this crate represents an early stage of a process before those actions have happened.
60+ """
61+ )
62+ def test_valid_five_safes_crate_request_recommended ():
63+ """Test a valid Five Safes Crate representing a request."""
64+ do_entity_test (
65+ ValidROC ().five_safes_crate_request ,
66+ Severity .RECOMMENDED ,
67+ True ,
68+ profile_identifier = "five-safes-crate" ,
69+ skip_checks = [
70+ SKIP_LOCAL_DATA_ENTITY_EXISTENCE_CHECK_IDENTIFIER ,
71+ SKIP_WEB_RESOURCE_AVAILABILITY_IDENTIFIER ,
72+ ],
73+ disable_inherited_profiles_reporting = True ,
74+ )
75+
76+
4077def test_valid_five_safes_crate_result_required ():
4178 """Test a valid Five Safes Crate representing a result."""
4279 do_entity_test (
@@ -50,6 +87,21 @@ def test_valid_five_safes_crate_result_required():
5087 )
5188
5289
90+ def test_valid_five_safes_crate_result_recommended ():
91+ """Test a valid Five Safes Crate representing a result."""
92+ do_entity_test (
93+ ValidROC ().five_safes_crate_result ,
94+ Severity .RECOMMENDED ,
95+ True ,
96+ profile_identifier = "five-safes-crate" ,
97+ skip_checks = [
98+ SKIP_LOCAL_DATA_ENTITY_EXISTENCE_CHECK_IDENTIFIER ,
99+ SKIP_WEB_RESOURCE_AVAILABILITY_IDENTIFIER ,
100+ ],
101+ disable_inherited_profiles_reporting = True ,
102+ )
103+
104+
53105def test_valid_five_safes_crate_multiple_context ():
54106 """Test a valid Five Safes Crate representing a result."""
55107 do_entity_test (
0 commit comments