From 0b954d6a00a3d44aba2b53ba4ffcf815b82d32b5 Mon Sep 17 00:00:00 2001 From: Nora-Olivia-Ammann <103038637+Nora-Olivia-Ammann@users.noreply.github.com> Date: Thu, 23 Jan 2025 11:05:53 +0100 Subject: [PATCH] feat(validate-data): validate `knora-api:Region` (DEV-4462) (#1380) --- .../commands/validate_data/constants.py | 4 +- .../validate_data/deserialise_input.py | 31 +++++++- .../validate_data/models/data_deserialised.py | 1 + src/dsp_tools/commands/validate_data/utils.py | 4 +- .../commands/validate_data/validate_data.py | 2 +- .../api-shapes-with-cardinalities.ttl | 30 +++++++- .../resources/validate_data/api-shapes.ttl | 77 ++++++++++++++++++- test/e2e_validate_data/test_validate_data.py | 3 + .../fixtures/validation_result.py | 46 +++++++++++ .../validate_data/fixtures/xml_data.py | 6 +- .../validate_data/test_deserialise_input.py | 31 +++++++- .../test_reformat_validaton_result.py | 42 ++++++++++ .../generic/dsp_inbuilt_correct.xml | 52 +++++++++++++ .../generic/dsp_inbuilt_violation.xml | 72 ++++++++++++++++- testdata/validate-data/knora-api-subset.ttl | 63 ++++++++++++--- 15 files changed, 438 insertions(+), 26 deletions(-) diff --git a/src/dsp_tools/commands/validate_data/constants.py b/src/dsp_tools/commands/validate_data/constants.py index bf44ad5e9..3ed65d433 100644 --- a/src/dsp_tools/commands/validate_data/constants.py +++ b/src/dsp_tools/commands/validate_data/constants.py @@ -15,6 +15,7 @@ from dsp_tools.commands.xmlupload.make_rdf_graph.constants import BOOLEAN_PROP_TYPE_INFO from dsp_tools.commands.xmlupload.make_rdf_graph.constants import COLOR_PROP_TYPE_INFO from dsp_tools.commands.xmlupload.make_rdf_graph.constants import DECIMAL_PROP_TYPE_INFO +from dsp_tools.commands.xmlupload.make_rdf_graph.constants import GEOMETRY_PROP_TYPE_INFO from dsp_tools.commands.xmlupload.make_rdf_graph.constants import GEONAME_PROP_TYPE_INFO from dsp_tools.commands.xmlupload.make_rdf_graph.constants import INT_PROP_TYPE_INFO from dsp_tools.commands.xmlupload.make_rdf_graph.constants import RICHTEXT_PROP_TYPE_INFO @@ -31,7 +32,6 @@ KNORA_API_STR = "http://api.knora.org/ontology/knora-api/v2#" API_SHAPES_STR = "http://api.knora.org/ontology/knora-api/shapes/v2#" -REGION_RESOURCE = KNORA_API_STR + "Region" LINKOBJ_RESOURCE = KNORA_API_STR + "LinkObj" VIDEO_SEGMENT_RESOURCE = KNORA_API_STR + "VideoSegment" AUDIO_SEGMENT_RESOURCE = KNORA_API_STR + "AudioSegment" @@ -90,6 +90,7 @@ KnoraValueType.DATE_VALUE: RDFPropTypeInfo(KNORA_API.DateValue, KNORA_API.valueAsString, XSD.string), KnoraValueType.DECIMAL_VALUE: DECIMAL_PROP_TYPE_INFO, KnoraValueType.GEONAME_VALUE: GEONAME_PROP_TYPE_INFO, + KnoraValueType.GEOM_VALUE: GEOMETRY_PROP_TYPE_INFO, KnoraValueType.LIST_VALUE: RDFPropTypeInfo(KNORA_API.ListValue, API_SHAPES.listNodeAsString, XSD.string), KnoraValueType.LINK_VALUE: RDFPropTypeInfo(KNORA_API.LinkValue, API_SHAPES.linkValueHasTargetID, XSD.string), KnoraValueType.INT_VALUE: INT_PROP_TYPE_INFO, @@ -111,6 +112,7 @@ KnoraValueType.COLOR_VALUE: TripleObjectType.STRING, KnoraValueType.DATE_VALUE: TripleObjectType.STRING, KnoraValueType.DECIMAL_VALUE: TripleObjectType.DECIMAL, + KnoraValueType.GEOM_VALUE: TripleObjectType.STRING, KnoraValueType.GEONAME_VALUE: TripleObjectType.STRING, KnoraValueType.LIST_VALUE: TripleObjectType.STRING, KnoraValueType.LINK_VALUE: TripleObjectType.IRI, diff --git a/src/dsp_tools/commands/validate_data/deserialise_input.py b/src/dsp_tools/commands/validate_data/deserialise_input.py index dadc78a7e..f9293ee19 100644 --- a/src/dsp_tools/commands/validate_data/deserialise_input.py +++ b/src/dsp_tools/commands/validate_data/deserialise_input.py @@ -1,10 +1,11 @@ +import json +from json import JSONDecodeError from pathlib import Path from lxml import etree from dsp_tools.commands.validate_data.constants import AUDIO_SEGMENT_RESOURCE from dsp_tools.commands.validate_data.constants import KNORA_API_STR -from dsp_tools.commands.validate_data.constants import REGION_RESOURCE from dsp_tools.commands.validate_data.constants import VIDEO_SEGMENT_RESOURCE from dsp_tools.commands.validate_data.constants import XML_ATTRIB_TO_PROP_TYPE_MAPPER from dsp_tools.commands.validate_data.constants import XML_TAG_TO_VALUE_TYPE_MAPPER @@ -43,9 +44,7 @@ def _deserialise_all_resources(root: etree._Element) -> DataDeserialised: for res in root.iterdescendants(tag="resource"): dsp_type = None res_type = res.attrib["restype"] - if res_type == REGION_RESOURCE: - dsp_type = REGION_RESOURCE - elif res_type == VIDEO_SEGMENT_RESOURCE: + if res_type == VIDEO_SEGMENT_RESOURCE: dsp_type = VIDEO_SEGMENT_RESOURCE elif res_type == AUDIO_SEGMENT_RESOURCE: dsp_type = AUDIO_SEGMENT_RESOURCE @@ -101,6 +100,8 @@ def _deserialise_one_property(prop_ele: etree._Element) -> list[ValueInformation return _extract_text_value_information(prop_ele) case "iiif-uri" | "bitstream" as file_tag: return _deserialise_file_values(prop_ele, file_tag) + case "geometry-prop": + return _extract_geometry_value_information(prop_ele) case _: return [] @@ -169,6 +170,28 @@ def _extract_text_value_information(prop: etree._Element) -> list[ValueInformati return all_vals +def _extract_geometry_value_information(prop: etree._Element) -> list[ValueInformation]: + prop_name = prop.attrib["name"] + + def check_for_geometry_json(value: str | None) -> str | None: + if not value: + return None + try: + return json.dumps(json.loads(value)) + except JSONDecodeError: + return None + + return [ + ValueInformation( + user_facing_prop=prop_name, + user_facing_value=check_for_geometry_json(val.text), + knora_type=KnoraValueType.GEOM_VALUE, + value_metadata=_extract_metadata_of_value(val), + ) + for val in prop.iterchildren() + ] + + def _get_text_as_string(value: etree._Element) -> str | None: if len(value): text_list = [] diff --git a/src/dsp_tools/commands/validate_data/models/data_deserialised.py b/src/dsp_tools/commands/validate_data/models/data_deserialised.py index 22faf1ffb..b917c8c31 100644 --- a/src/dsp_tools/commands/validate_data/models/data_deserialised.py +++ b/src/dsp_tools/commands/validate_data/models/data_deserialised.py @@ -120,6 +120,7 @@ class KnoraValueType(Enum): DATE_VALUE = auto() DECIMAL_VALUE = auto() GEONAME_VALUE = auto() + GEOM_VALUE = auto() INT_VALUE = auto() LINK_VALUE = auto() LIST_VALUE = auto() diff --git a/src/dsp_tools/commands/validate_data/utils.py b/src/dsp_tools/commands/validate_data/utils.py index be8eedbf5..a6093e7db 100644 --- a/src/dsp_tools/commands/validate_data/utils.py +++ b/src/dsp_tools/commands/validate_data/utils.py @@ -1,7 +1,7 @@ from rdflib.term import Node -def reformat_onto_iri(iri: Node) -> str: +def reformat_onto_iri(iri: Node | str) -> str: """Takes a rdflib Node and returns a prefixed IRI in string form.""" iri_str = str(iri) if "http://www.w3.org/2000/01/rdf-schema#" in iri_str: @@ -13,6 +13,6 @@ def reformat_onto_iri(iri: Node) -> str: return f"{onto}:{ending}" -def reformat_data_iri(iri: Node) -> str: +def reformat_data_iri(iri: Node | str) -> str: """Takes a rdflib Node with in the data namespace and returns only the suffix.""" return str(iri).replace("http://data/", "") diff --git a/src/dsp_tools/commands/validate_data/validate_data.py b/src/dsp_tools/commands/validate_data/validate_data.py index d18401d1f..fb4d0ec4c 100644 --- a/src/dsp_tools/commands/validate_data/validate_data.py +++ b/src/dsp_tools/commands/validate_data/validate_data.py @@ -120,7 +120,7 @@ def _inform_about_experimental_feature() -> None: "Content of the values", "Missing files", "If the file type matches the ontology", - "DSP in-built resources: link (LinkObj)", + "DSP in-built resources: link (LinkObj), region", ] print(BOLD_CYAN + LIST_SEPARATOR.join(what_is_validated) + RESET_TO_DEFAULT) diff --git a/src/dsp_tools/resources/validate_data/api-shapes-with-cardinalities.ttl b/src/dsp_tools/resources/validate_data/api-shapes-with-cardinalities.ttl index aea336e44..bff243dd4 100644 --- a/src/dsp_tools/resources/validate_data/api-shapes-with-cardinalities.ttl +++ b/src/dsp_tools/resources/validate_data/api-shapes-with-cardinalities.ttl @@ -24,7 +24,7 @@ api-shapes:rdfsLabel_Cardinality ########################### # LinkObj -api-shapes:LinkObj_Cardinalities +knora-api:LinkObj a sh:NodeShape ; dash:closedByTypes true ; sh:property api-shapes:rdfsLabel_Cardinality , @@ -42,10 +42,34 @@ api-shapes:LinkObj_Cardinalities ########################### # Region -api-shapes:Region_Cardinalities +knora-api:Region a sh:NodeShape ; dash:closedByTypes true ; - sh:property api-shapes:rdfsLabel_Cardinality . + sh:property api-shapes:rdfsLabel_Cardinality , + [ + a sh:PropertyShape ; + sh:path knora-api:hasComment + ] , + [ a sh:PropertyShape ; + sh:message "1" ; + sh:minCount 1 ; + sh:maxCount 1 ; + sh:path knora-api:hasColor ; + sh:severity sh:Violation + ] , + [ a sh:PropertyShape ; + sh:message "1" ; + sh:minCount 1 ; + sh:maxCount 1 ; + sh:path knora-api:isRegionOf ; + sh:severity sh:Violation + ] , + [ a sh:PropertyShape ; + sh:message "1-n" ; + sh:minCount 1 ; + sh:path knora-api:hasGeometry ; + sh:severity sh:Violation + ] . ########################### # VideoSegment diff --git a/src/dsp_tools/resources/validate_data/api-shapes.ttl b/src/dsp_tools/resources/validate_data/api-shapes.ttl index 186d00300..6a5f4aa60 100644 --- a/src/dsp_tools/resources/validate_data/api-shapes.ttl +++ b/src/dsp_tools/resources/validate_data/api-shapes.ttl @@ -87,7 +87,15 @@ api-shapes:ColorValue_ClassShape sh:name "Validates the class type" ; sh:message "ColorValue" ; sh:class knora-api:ColorValue ; - sh:property api-shapes:valueHasComment_Shape ; + sh:property api-shapes:colorValueAsColor_Shape, api-shapes:valueHasComment_Shape ; + sh:severity sh:Violation . + +api-shapes:colorValueAsColor_Shape + a sh:PropertyShape ; + sh:message "The value must be a valid color" ; + sh:path knora-api:colorValueAsColor ; + sh:pattern "^#([0-9a-fA-F]{3}){1,2}$" ; + sh:datatype xsd:string ; sh:severity sh:Violation . @@ -138,6 +146,27 @@ api-shapes:geonameValueAsGeonameCode_Shape sh:severity sh:Violation . +############## +# GeomValue +############## + +api-shapes:GeomValue_ClassShape + a sh:NodeShape ; + sh:name "Validates the class type" ; + sh:message "GeomValue" ; + sh:property api-shapes:geometryValueAsGeometry_Shape, api-shapes:valueHasComment_Shape ; + sh:class knora-api:GeomValue ; + sh:severity sh:Violation . + +api-shapes:geometryValueAsGeometry_Shape + a sh:PropertyShape ; + sh:message "The value must be a valid geometry JSON object" ; + sh:path knora-api:geometryValueAsGeometry ; + sh:pattern "\\s*\\S+\\s*" ; + sh:datatype xsd:string ; + sh:severity sh:Violation . + + ############## # IntValue ############## @@ -283,6 +312,25 @@ api-shapes:hasLinkTo_NodeShape sh:severity sh:Violation . +### knora-api:isRegionOf + +api-shapes:isRegionOf_PropertyShape + a sh:PropertyShape ; + sh:path knora-api:isRegionOf ; + sh:node api-shapes:LinkValue_ClassShape, api-shapes:isRegionOf_NodeShape . + +api-shapes:isRegionOf_NodeShape + a sh:NodeShape ; + sh:name "This ensures that the target of the property is of type Representation, i.e. exists in the graph." ; + sh:property [ + a sh:PropertyShape ; + sh:class knora-api:Representation ; + sh:message "http://api.knora.org/ontology/knora-api/v2#Representation" ; + sh:path api-shapes:linkValueHasTargetID ; + ] ; + sh:severity sh:Violation . + + ### knora-api:hasComment api-shapes:hasComment_PropertyShape @@ -304,6 +352,22 @@ api-shapes:valueHasComment_Shape sh:severity sh:Violation . +### knora-api:hasColor + +api-shapes:hasColor_PropertyShape + a sh:PropertyShape ; + sh:node api-shapes:ColorValue_ClassShape ; + sh:path knora-api:hasColor . + + +### knora-api:hasGeometry + +api-shapes:hasGeometry_PropertyShape + a sh:PropertyShape ; + sh:node api-shapes:GeomValue_ClassShape ; + sh:path knora-api:hasGeometry . + + ### knora-api:seqnum and knora-api:isPartOf # dash:coExistsWith ensures that isPartOf also needs seqnum. There is no need for a second shape. @@ -336,6 +400,17 @@ api-shapes:LinkObj_ResourceShape ########################### # Region +api-shapes:Region_ResourceShape + a sh:NodeShape ; + sh:name "Validates the Region resource" ; + sh:targetClass knora-api:Region ; + sh:property api-shapes:rdfsLabel_Shape , + api-shapes:hasColor_PropertyShape , + api-shapes:isRegionOf_PropertyShape , + api-shapes:hasGeometry_PropertyShape , + api-shapes:hasComment_PropertyShape ; + sh:severity sh:Violation . + ########################### # VideoSegment diff --git a/test/e2e_validate_data/test_validate_data.py b/test/e2e_validate_data/test_validate_data.py index ccad7e466..c38c4d840 100644 --- a/test/e2e_validate_data/test_validate_data.py +++ b/test/e2e_validate_data/test_validate_data.py @@ -474,6 +474,9 @@ def test_reformat_dsp_inbuilt_violation(self, dsp_inbuilt_violation: ValidationR ("link_obj_target_non_existent", LinkedResourceDoesNotExistProblem), ("missing_isPartOf", GenericProblemWithMessage), ("missing_seqnum", GenericProblemWithMessage), + ("region_invalid_geometry", InputRegexProblem), + ("region_isRegionOf_resource_does_not_exist", LinkedResourceDoesNotExistProblem), + ("region_isRegionOf_resource_not_a_representation", LinkTargetTypeMismatchProblem), ("target_must_be_a_representation", LinkTargetTypeMismatchProblem), ("target_must_be_an_image_representation", LinkTargetTypeMismatchProblem), ] diff --git a/test/unittests/commands/validate_data/fixtures/validation_result.py b/test/unittests/commands/validate_data/fixtures/validation_result.py index 697d31f65..888e8955a 100644 --- a/test/unittests/commands/validate_data/fixtures/validation_result.py +++ b/test/unittests/commands/validate_data/fixtures/validation_result.py @@ -37,6 +37,52 @@ def onto_graph() -> Graph: return g +@pytest.fixture +def report_target_resource_wrong_type(onto_graph: Graph) -> tuple[Graph, Graph]: + validation_str = f"""{PREFIXES} + [ + a sh:ValidationResult ; + sh:detail _:detail_bn ; + sh:focusNode ; + sh:resultMessage "Value does not have shape api-shapes:isRegionOf_NodeShape" ; + sh:resultPath ; + sh:resultSeverity sh:Violation ; + sh:sourceConstraintComponent sh:NodeConstraintComponent ; + sh:sourceShape ; + sh:value + ] . + + _:detail_bn a sh:ValidationResult ; + sh:focusNode ; + sh:resultMessage "http://api.knora.org/ontology/knora-api/v2#Representation" ; + sh:resultPath ; + sh:resultSeverity sh:Violation ; + sh:sourceConstraintComponent sh:ClassConstraintComponent ; + sh:sourceShape _:source_shape ; + sh:value . + """ + validation_g = Graph() + validation_g.parse(data=validation_str, format="ttl") + data_str = f"""{PREFIXES} + + a knora-api:Region ; + rdfs:label "Region"^^xsd:string ; + knora-api:hasColor ; + knora-api:hasGeometry ; + knora-api:isRegionOf . + + a knora-api:LinkValue ; + api-shapes:linkValueHasTargetID . + + a in-built:TestNormalResource ; + rdfs:label "Resource without Representation"^^xsd:string . + """ + onto_data_g = Graph() + onto_data_g += onto_graph + onto_data_g.parse(data=data_str, format="ttl") + return validation_g, onto_data_g + + @pytest.fixture def report_not_resource(onto_graph: Graph) -> tuple[Graph, Graph]: validation_str = f"""{PREFIXES} diff --git a/test/unittests/commands/validate_data/fixtures/xml_data.py b/test/unittests/commands/validate_data/fixtures/xml_data.py index 110c7b73c..b636e9d16 100644 --- a/test/unittests/commands/validate_data/fixtures/xml_data.py +++ b/test/unittests/commands/validate_data/fixtures/xml_data.py @@ -151,7 +151,7 @@ def decimal_value_corr_several() -> etree._Element: @pytest.fixture def geometry_value_corr() -> etree._Element: return etree.fromstring(""" - + { "status": "active", @@ -170,8 +170,8 @@ def geometry_value_corr() -> etree._Element: @pytest.fixture def geometry_value_wrong() -> etree._Element: return etree.fromstring(""" - - + + { not geometry } """) diff --git a/test/unittests/commands/validate_data/test_deserialise_input.py b/test/unittests/commands/validate_data/test_deserialise_input.py index 810be7e60..dcac1faea 100644 --- a/test/unittests/commands/validate_data/test_deserialise_input.py +++ b/test/unittests/commands/validate_data/test_deserialise_input.py @@ -1,6 +1,7 @@ import pytest from lxml import etree +from dsp_tools.commands.validate_data.constants import KNORA_API_STR from dsp_tools.commands.validate_data.deserialise_input import _deserialise_all_resources from dsp_tools.commands.validate_data.deserialise_input import _deserialise_one_property from dsp_tools.commands.validate_data.deserialise_input import _deserialise_one_resource @@ -54,7 +55,15 @@ def test_region(self, root_resource_region: etree._Element) -> None: assert lbl.object_type == TripleObjectType.STRING assert rdf_type.object_value == "http://api.knora.org/ontology/knora-api/v2#Region" assert rdf_type.object_type == TripleObjectType.IRI - assert len(res.values) == 0 + assert len(res.values) == 4 + expected_props = { + f"{KNORA_API_STR}hasColor", + f"{KNORA_API_STR}isRegionOf", + f"{KNORA_API_STR}hasGeometry", + f"{KNORA_API_STR}hasComment", + } + actual_props = {x.user_facing_prop for x in res.values} + assert actual_props == expected_props class TestBooleanValue: @@ -148,6 +157,26 @@ def test_several(self, geoname_value_corr_several: etree._Element) -> None: assert res[1].knora_type == KnoraValueType.GEONAME_VALUE +class TestGeomValue: + def test_corr(self, geometry_value_corr: etree._Element) -> None: + res_list = _deserialise_one_property(geometry_value_corr) + assert len(res_list) == 1 + res = res_list[0] + assert res.user_facing_prop == f"{KNORA_API_STR}hasGeometry" + assert res.user_facing_value is not None + assert res.knora_type == KnoraValueType.GEOM_VALUE + assert not res.value_metadata + + def test_wrong(self, geometry_value_wrong: etree._Element) -> None: + res_list = _deserialise_one_property(geometry_value_wrong) + assert len(res_list) == 1 + res = res_list[0] + assert res.user_facing_prop == f"{KNORA_API_STR}hasGeometry" + assert not res.user_facing_value + assert res.knora_type == KnoraValueType.GEOM_VALUE + assert not res.value_metadata + + class TestIntValue: def test_corr(self, integer_value_corr: etree._Element) -> None: res_list = _deserialise_one_property(integer_value_corr) diff --git a/test/unittests/commands/validate_data/test_reformat_validaton_result.py b/test/unittests/commands/validate_data/test_reformat_validaton_result.py index ed0469f40..24fdfe943 100644 --- a/test/unittests/commands/validate_data/test_reformat_validaton_result.py +++ b/test/unittests/commands/validate_data/test_reformat_validaton_result.py @@ -30,17 +30,59 @@ from dsp_tools.commands.validate_data.models.validation import ResultValueTypeViolation from dsp_tools.commands.validate_data.models.validation import SeqnumIsPartOfViolation from dsp_tools.commands.validate_data.models.validation import UnexpectedComponent +from dsp_tools.commands.validate_data.models.validation import ValidationReportGraphs from dsp_tools.commands.validate_data.models.validation import ValidationResultBaseInfo from dsp_tools.commands.validate_data.reformat_validaton_result import _extract_base_info_of_resource_results +from dsp_tools.commands.validate_data.reformat_validaton_result import _query_all_results from dsp_tools.commands.validate_data.reformat_validaton_result import _query_one_with_detail from dsp_tools.commands.validate_data.reformat_validaton_result import _query_one_without_detail from dsp_tools.commands.validate_data.reformat_validaton_result import _reformat_one_validation_result from dsp_tools.commands.validate_data.reformat_validaton_result import _separate_result_types +from dsp_tools.commands.validate_data.reformat_validaton_result import reformat_validation_graph from test.unittests.commands.validate_data.constants import DATA +from test.unittests.commands.validate_data.constants import IN_BUILT_ONTO from test.unittests.commands.validate_data.constants import KNORA_API from test.unittests.commands.validate_data.constants import ONTO +def test_reformat_validation_graph(report_target_resource_wrong_type: tuple[Graph, Graph]) -> None: + validation_g, onto_data_g = report_target_resource_wrong_type + report = ValidationReportGraphs( + conforms=False, + validation_graph=validation_g, + shacl_graph=Graph(), + onto_graph=onto_data_g, + data_graph=onto_data_g, + ) + result_all_problems = reformat_validation_graph(report) + assert not result_all_problems.unexpected_results + assert len(result_all_problems.problems) == 1 + result = result_all_problems.problems.pop(0) + assert isinstance(result, LinkTargetTypeMismatchProblem) + assert result.res_id == "region_isRegionOf_resource_not_a_representation" + assert result.res_type == "Region" + assert result.prop_name == "isRegionOf" + assert result.link_target_id == "target_res_without_representation_1" + assert result.actual_type == "in-built:TestNormalResource" + assert result.expected_type == "Representation" + + +class TestQueryAllResults: + def test_link_target_inexistent(self, report_target_resource_wrong_type: tuple[Graph, Graph]) -> None: + validation_g, onto_data_g = report_target_resource_wrong_type + extracted_results, unexpected_components = _query_all_results(validation_g, onto_data_g) + assert not unexpected_components + assert len(extracted_results) == 1 + result = extracted_results.pop(0) + assert isinstance(result, ResultLinkTargetViolation) + assert result.res_iri == DATA.region_isRegionOf_resource_not_a_representation + assert result.res_class == KNORA_API.Region + assert result.property == KNORA_API.isRegionOf + assert result.target_iri == DATA.target_res_without_representation_1 + assert result.target_resource_type == IN_BUILT_ONTO.TestNormalResource + assert str(result.expected_type) == "http://api.knora.org/ontology/knora-api/v2#Representation" + + class TestExtractBaseInfo: def test_not_resource(self, report_not_resource: tuple[Graph, Graph]) -> None: validation_g, onto_data_g = report_not_resource diff --git a/testdata/validate-data/generic/dsp_inbuilt_correct.xml b/testdata/validate-data/generic/dsp_inbuilt_correct.xml index 227317292..760c0634c 100644 --- a/testdata/validate-data/generic/dsp_inbuilt_correct.xml +++ b/testdata/validate-data/generic/dsp_inbuilt_correct.xml @@ -40,6 +40,58 @@ + + + + + #5d1f1e + + + target_empty_image + + + + { + "status": "active", + "type": "polygon", + "lineWidth": 5, + "points": [{"x": 0.4, "y": 0.6}, + {"x": 0.5, "y": 0.9}, + {"x": 0.8, "y": 0.9}, + {"x": 0.7, "y": 0.6}] + } + + + + Comment Text + + + + + + + + #5d1f1e + + + target_empty_image + + + + { + "status": "active", + "type": "polygon", + "lineWidth": 5, + "points": [{"x": 0.4, "y": 0.6}, + {"x": 0.5, "y": 0.9}, + {"x": 0.8, "y": 0.9}, + {"x": 0.7, "y": 0.6}] + } + + + + + - + @@ -21,6 +21,11 @@ this/is/filepath/file.mp4 + + this/is/filepath/file.jpg + + + @@ -29,6 +34,71 @@ + + + + + #5d1f1e + + + target_does_not_exist + + + + { + "status": "active", + "type": "polygon", + "lineWidth": 5, + "points": [{"x": 0.4, "y": 0.6}, + {"x": 0.5, "y": 0.9}, + {"x": 0.8, "y": 0.9}, + {"x": 0.7, "y": 0.6}] + } + + + + + + + + + #5d1f1e + + + target_res_without_representation_1 + + + + { + "status": "active", + "type": "polygon", + "lineWidth": 5, + "points": [{"x": 0.4, "y": 0.6}, + {"x": 0.5, "y": 0.9}, + {"x": 0.8, "y": 0.9}, + {"x": 0.7, "y": 0.6}] + } + + + + + + + + + #5d1f1e + + + target_empty_image + + + + { not a valid json } + + + + + . -@prefix owl: . -@prefix rdfs: . +@prefix owl: . +@prefix rdfs: . -knora-api:ArchiveRepresentation a owl:Class ; +knora-api:ArchiveRepresentation + a owl:Class ; rdfs:subClassOf knora-api:Representation . -knora-api:AudioRepresentation a owl:Class ; +knora-api:AudioRepresentation + a owl:Class ; rdfs:subClassOf knora-api:Representation . -knora-api:DocumentRepresentation a owl:Class ; +knora-api:DocumentRepresentation + a owl:Class ; rdfs:subClassOf knora-api:Representation . -knora-api:MovingImageRepresentation a owl:Class ; +knora-api:MovingImageRepresentation + a owl:Class ; rdfs:subClassOf knora-api:Representation . -knora-api:StillImageRepresentation a owl:Class ; +knora-api:StillImageRepresentation + a owl:Class ; rdfs:subClassOf knora-api:Representation . -knora-api:TextRepresentation a owl:Class ; +knora-api:TextRepresentation + a owl:Class ; rdfs:subClassOf knora-api:Representation . -knora-api:Representation a owl:Class ; +knora-api:Representation + a owl:Class ; rdfs:subClassOf knora-api:Resource . knora-api:Resource a owl:Class . + +knora-api:LinkObj + a owl:Class ; + rdfs:subClassOf knora-api:Resource ; + rdfs:label "Link Object" ; + knora-api:canBeInstantiated true ; + knora-api:isResourceClass true . + + +knora-api:Region + a owl:Class ; + rdfs:subClassOf knora-api:Resource ; + rdfs:label "Region" ; + knora-api:canBeInstantiated true ; + knora-api:isResourceClass true . + + +knora-api:Segment + a owl:Class ; + rdfs:subClassOf knora-api:Resource ; + rdfs:label "Segment" ; + knora-api:isResourceClass true . + + +knora-api:AudioSegment + a owl:Class ; + rdfs:subClassOf knora-api:Segment ; + rdfs:label "Audiosegment" ; + knora-api:canBeInstantiated true ; + knora-api:isResourceClass true . + + +knora-api:VideoSegment + a owl:Class ; + rdfs:subClassOf knora-api:Segment ; + rdfs:label "VideoSegment" ; + knora-api:canBeInstantiated true ; + knora-api:isResourceClass true .