def test_validate_many(self, rdf_model: RdfModel, valid_activity_resource,
                        invalid_activity_resource):
     resources = [valid_activity_resource, invalid_activity_resource]
     rdf_model.validate(resources, False)
     assert valid_activity_resource._validated is True
     assert invalid_activity_resource._validated is False
     assert (valid_activity_resource._last_action.operation ==
             invalid_activity_resource._last_action.operation ==
             rdf_model._validate_many.__name__)
 def test_type_to_schema(self, rdf_model: RdfModel, type_):
     # FIXME TYPES_SCHEMAS_MAP should be a type to file dictionary
     assert rdf_model.schema_id(type_) == TYPES_SCHEMAS_MAP[type_]
 def test_create_templates_only_required(self, rdf_model: RdfModel, type_,
                                         expected):
     result = rdf_model._template(type_, True)
     assert result == expected
 def test_create_templates(self, rdf_model: RdfModel, type_, expected):
     result = rdf_model._template(type_, False)
     assert result == expected
 def test_request_invalid_type(self, rdf_model: RdfModel):
     with pytest.raises(ValueError):
         rdf_model._template("Invalid", False)
 def test_namespaces(self, rdf_model: RdfModel, model_prefixes):
     assert rdf_model.prefixes(pretty=False) == model_prefixes
 def test_context(self, rdf_model: RdfModel, context_file_path):
     with open(context_file_path) as f:
         expected = json.load(f)
     vocabulary = rdf_model.context().document
     assert vocabulary == expected
 def test_types(self, rdf_model: RdfModel):
     types = rdf_model.types(pretty=False)
     assert types == list(TYPES_SCHEMAS_MAP.keys())
 def test_generate_context(self, rdf_model: RdfModel):
     generated_context = rdf_model._generate_context()
     for k in TYPES_SCHEMAS_MAP.keys():
         assert generated_context.expand(k) is not None
示例#10
0
def rdf_model(context_iri_file):
    return RdfModel("tests/data/shacl-model",
                    context={"iri": context_iri_file},
                    origin="directory")
示例#11
0
 def test_validate_one_fail(self, rdf_model: RdfModel,
                            invalid_activity_resource):
     with pytest.raises(ValidationError):
         rdf_model._validate_one(invalid_activity_resource)
示例#12
0
 def test_validate_one(self, rdf_model: RdfModel, valid_activity_resource):
     rdf_model.validate(valid_activity_resource, False)