Commit 23c33bce authored by Fabien Amarger's avatar Fabien Amarger
Browse files

feat: Add CWUri entity type to store URI from fragment

parent 505c8f18b945
......@@ -176,6 +176,22 @@
)
)
if "CWUri" in schema:
raise ValueError("CWUri is reserved keyword, please rename it in your model")
cwuri_entitytype = schema.add_entity_type(EntityType("CWUri"))
if "cw_fragment" in schema:
raise ValueError(
"'cw_fragment' is reserved keyword, please rename it in your model"
)
cw_fragment_type = schema.add_relation_type(RelationType("cw_fragment"))
schema.add_relation_def(
RelationDefinition(cwuri_entitytype, cw_fragment_type, "String")
)
if "cw_uri" in schema:
raise ValueError("'cw_uri' is reserved keyword, please rename it in your model")
cw_uri_type = schema.add_relation_type(RelationType("cw_uri"))
schema.add_relation_def(RelationDefinition(cwuri_entitytype, cw_uri_type, "String"))
return schema
......
from yams.buildobjs import *
class CWUri(EntityType):
cw_fragment = String()
cw_uri = String()
......@@ -10,7 +10,10 @@
class Owl2YamsTC(unittest.TestCase):
def _load_owl_and_yams(
self, owl_model_file_name: str, yams_schema_file_name: Optional[str] = None
self,
owl_model_file_name: str,
yams_schema_file_name: Optional[str] = None,
check_cw_uri: bool = False,
):
data_input = TEST_DATA / owl_model_file_name
owl_model = Graph()
......@@ -18,6 +21,9 @@
schema = owl_model_to_yams(owl_model, "TEST")
if not check_cw_uri:
schema.del_entity_type("CWUri")
if yams_schema_file_name is not None:
expected_output = TEST_DATA / yams_schema_file_name
with open(expected_output) as f:
......@@ -49,6 +55,9 @@
with self.assertRaises(ValueError):
self._load_owl_and_yams("test_multi_relation.owl")
def test_cwuri(self):
self._load_owl_and_yams("test_cwuri.owl", "test_cwuri.yams", check_cw_uri=True)
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