File tree Expand file tree Collapse file tree 3 files changed +60
-4
lines changed
tests/unit/synapseclient/extensions Expand file tree Collapse file tree 3 files changed +60
-4
lines changed Original file line number Diff line number Diff line change @@ -60,11 +60,20 @@ def helpers():
6060
6161@pytest .fixture (name = "dmge" , scope = "function" )
6262def DMGE (helpers : Helpers ) -> DataModelGraphExplorer :
63- """Fixture to instantiate a DataModelGraphExplorer object using the data model with column types """
63+ """Fixture to instantiate a DataModelGraphExplorer object using the csv data model"""
6464 dmge = helpers .get_data_model_graph_explorer (path = "data_models/example.model.csv" )
6565 return dmge
6666
6767
68+ @pytest .fixture (name = "dmge_json_ld" , scope = "function" )
69+ def dmge_json_ld (helpers : Helpers ) -> DataModelGraphExplorer :
70+ """Fixture to instantiate a DataModelGraphExplorer object using the jsonls data model"""
71+ dmge = helpers .get_data_model_graph_explorer (
72+ path = "data_models_jsonld/example.model.jsonld"
73+ )
74+ return dmge
75+
76+
6877@pytest .fixture (name = "dmr" )
6978def fixture_dmr ():
7079 "Returns a DataModelRelationships instance"
@@ -82,7 +91,9 @@ def fixture_dmp(helpers: Helpers) -> DataModelParser:
8291@pytest .fixture (name = "dmp_jsonld" )
8392def fixture_dmp_json_ld (helpers : Helpers ) -> DataModelParser :
8493 "Returns a DataModelParser using the jsonld data model"
85- data_model_path = helpers .get_schema_file_path ("data_models/example.model.jsonld" )
94+ data_model_path = helpers .get_schema_file_path (
95+ "data_models_jsonld/example.model.jsonld"
96+ )
8697 dmp = DataModelParser (data_model_path , logger = Mock ())
8798 return dmp
8899
Original file line number Diff line number Diff line change @@ -638,6 +638,51 @@ def test_create_json_schema_with_display_names(
638638 assert expected_json == test_json
639639
640640
641+ @pytest .mark .parametrize (
642+ "datatype" ,
643+ [
644+ ("Biospecimen" ),
645+ ("BulkRNA-seqAssay" ),
646+ ("JSONSchemaComponent" ),
647+ ("MockComponent" ),
648+ ("MockFilename" ),
649+ ("MockRDB" ),
650+ ("Patient" ),
651+ ],
652+ ids = [
653+ "Biospecimen" ,
654+ "BulkRNA-seqAssay" ,
655+ "JSONSchemaComponent" ,
656+ "MockComponent" ,
657+ "MockFilename" ,
658+ "MockRDB" ,
659+ "Patient" ,
660+ ],
661+ )
662+ def test_create_json_schema_with_class_label_using_jsonld (
663+ dmge_json_ld : DataModelGraphExplorer , datatype : str , test_directory : str
664+ ) -> None :
665+ """Tests for JSONSchemaGenerator.create_json_schema"""
666+ test_path = get_test_schema_path (test_directory , datatype )
667+ expected_path = get_expected_schema_path (datatype )
668+ logger = logging .getLogger (__name__ )
669+
670+ create_json_schema (
671+ dmge = dmge_json_ld ,
672+ datatype = datatype ,
673+ schema_name = f"{ datatype } _validation" ,
674+ schema_path = test_path ,
675+ use_property_display_names = False ,
676+ logger = logger ,
677+ )
678+ with open (expected_path , encoding = "utf-8" ) as file1 , open (
679+ test_path , encoding = "utf-8"
680+ ) as file2 :
681+ expected_json = json .load (file1 )
682+ test_json = json .load (file2 )
683+ assert expected_json == test_json
684+
685+
641686@pytest .mark .parametrize (
642687 "instance_filename, datatype" ,
643688 [
Original file line number Diff line number Diff line change @@ -96,7 +96,7 @@ def test_gather_jsonld_attributes_relationships(
9696 ):
9797 """The output of the function is a attributes relationship dictionary, check that it is formatted properly."""
9898 path_to_data_model = helpers .get_schema_file_path (
99- "data_models /example.model.jsonld"
99+ "data_models_jsonld /example.model.jsonld"
100100 )
101101 model_jsonld = load_json (path_to_data_model )
102102 attr_rel_dict = jsonld_dmp .gather_jsonld_attributes_relationships (
@@ -117,7 +117,7 @@ def test_parse_jsonld_model(
117117 ):
118118 """The output of the function is a attributes relationship dictionary, check that it is formatted properly."""
119119 path_to_data_model = helpers .get_schema_file_path (
120- "data_models /example.model.jsonld"
120+ "data_models_jsonld /example.model.jsonld"
121121 )
122122 attr_rel_dictionary = jsonld_dmp .parse_jsonld_model (
123123 path_to_data_model = path_to_data_model ,
You can’t perform that action at this time.
0 commit comments