Commit 3eeda7b1 authored by Fabien Amarger's avatar Fabien Amarger
Browse files

feat(owl2yams): Raise ValueError if attribute already defined

parent 0974d609a9e9
......@@ -67,7 +67,7 @@
if class_fragment is None:
print(f"Warning: class {class_uri} could not be parsed")
continue
if class_fragment in ETYPE_URI:
if class_fragment in schema:
raise ValueError(
f"Error: class {class_uri} and {ETYPE_URI[class_fragment]} use the same fragment"
)
......@@ -95,6 +95,10 @@
if datatype_property_uri_fragment is None:
print(f"Warning: data property {datatype_property_uri} could not be parsed")
continue
if datatype_property_uri_fragment in schema:
raise ValueError(
f"Error: attribute {datatype_property_uri} already defined"
)
schema.add_relation_type(RelationType(datatype_property_uri_fragment))
# take first range, if no range use RDFS.Literal
_, _, literal_type = next(
......
@prefix loutre: <http://loutre.fr/>.
@prefix loutre2: <http://loutre2.fr/>.
@prefix owl: <http://www.w3.org/2002/07/owl#>.
loutre:toto a owl:DatatypeProperty.
loutre2:toto a owl:DatatypeProperty.
......@@ -41,6 +41,10 @@
with self.assertRaises(ValueError):
self._load_owl_and_yams("test_multi_class.owl")
def test_raise_multi_attribute(self):
with self.assertRaises(ValueError):
self._load_owl_and_yams("test_multi_attribute.owl")
if __name__ == "__main__":
unittest.main()
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment