Commit 4a98155b authored by Fabien Amarger's avatar Fabien Amarger
Browse files

feat(test): Change how to declare test

parent 958ac60aedc2
import unittest
import pathlib
from rdflib import Graph
from typing import Optional
from owl2yams import owl_model_to_yams
from yams.serialize import serialize_to_python
......@@ -8,11 +9,12 @@
class Owl2YamsTC(unittest.TestCase):
def test_transform_owl_to_yams(self):
data_input = TEST_DATA / "model.owl"
expected_output = TEST_DATA / "expected_schema.yams"
def _load_owl_and_yams(
self, owl_model_file_name: str, yams_schema_file_name: Optional[str] = None
):
data_input = TEST_DATA / owl_model_file_name
owl_model = Graph()
owl_model.parse(str(data_input), format="turtle")
schema = owl_model_to_yams(owl_model, "TEST")
......@@ -14,11 +16,17 @@
owl_model = Graph()
owl_model.parse(str(data_input), format="turtle")
schema = owl_model_to_yams(owl_model, "TEST")
with open(expected_output) as f:
expected_yams_schema = f.read()
self.assertEquals(serialize_to_python(schema), expected_yams_schema)
if yams_schema_file_name is not None:
expected_output = TEST_DATA / yams_schema_file_name
with open(expected_output) as f:
expected_yams_schema = f.read()
self.assertEquals(serialize_to_python(schema), expected_yams_schema)
return schema
def test_transform_owl_to_yams(self):
self._load_owl_and_yams("model.owl", "expected_schema.yams")
if __name__ == "__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