Skip to content

Commit 296811d

Browse files
committed
add dmge using column type data model
1 parent 448b7d4 commit 296811d

File tree

2 files changed

+62
-0
lines changed

2 files changed

+62
-0
lines changed

tests/conftest.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,12 @@ def DMGE(helpers: Helpers) -> DataModelGraphExplorer:
238238
dmge = helpers.get_data_model_graph_explorer(path="example.model.jsonld")
239239
return dmge
240240

241+
@pytest.fixture(name="dmge_column_type", scope="function")
242+
def DMGE_column_type(helpers: Helpers) -> DataModelGraphExplorer:
243+
"""Fixture to instantiate a DataModelGraphExplorer object using the data model with column types"""
244+
dmge = helpers.get_data_model_graph_explorer(path="example.model.column_type_component.csv")
245+
return dmge
246+
241247

242248
@pytest.fixture(scope="function")
243249
def syn_token(config: Configuration):

tests/unit/test_create_json_schema.py

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -616,6 +616,62 @@ def test_create_json_schema_with_display_names(
616616
assert expected_json == test_json
617617

618618

619+
620+
def test_create_json_schema_with_no_column_type(
621+
dmge: DataModelGraphExplorer, test_directory: str
622+
) -> None:
623+
"""
624+
Tests for JSONSchemaGenerator.create_json_schema
625+
This tests where the data model does not have columnType attribute
626+
"""
627+
datatype = "JSONSchemaComponent"
628+
test_file = f"test.{datatype}.display_names_schema.json"
629+
test_path = os.path.join(test_directory, test_file)
630+
expected_path = (
631+
f"tests/data/expected_jsonschemas/expected.{datatype}.schema.json"
632+
)
633+
create_json_schema(
634+
dmge=dmge,
635+
datatype=datatype,
636+
schema_name=f"{datatype}_validation",
637+
schema_path=test_path,
638+
use_property_display_names=False,
639+
)
640+
with open(expected_path, encoding="utf-8") as file1, open(
641+
test_path, encoding="utf-8"
642+
) as file2:
643+
expected_json = json.load(file1)
644+
test_json = json.load(file2)
645+
assert expected_json == test_json
646+
647+
def test_create_json_schema_with_column_type(
648+
dmge_column_type: DataModelGraphExplorer, test_directory: str
649+
) -> None:
650+
"""
651+
Tests for JSONSchemaGenerator.create_json_schema
652+
This tests where the data model does have the columnType attribute
653+
"""
654+
datatype = "JSONSchemaComponent"
655+
test_file = f"test.{datatype}.display_names_schema.json"
656+
test_path = os.path.join(test_directory, test_file)
657+
expected_path = (
658+
f"tests/data/expected_jsonschemas/expected.{datatype}.schema.json"
659+
)
660+
create_json_schema(
661+
dmge=dmge_column_type,
662+
datatype=datatype,
663+
schema_name=f"{datatype}_validation",
664+
schema_path=test_path,
665+
use_property_display_names=False,
666+
)
667+
with open(expected_path, encoding="utf-8") as file1, open(
668+
test_path, encoding="utf-8"
669+
) as file2:
670+
expected_json = json.load(file1)
671+
test_json = json.load(file2)
672+
assert expected_json == test_json
673+
674+
619675
@pytest.mark.parametrize(
620676
"instance_path, datatype",
621677
[

0 commit comments

Comments
 (0)