77
88
99@pytest .mark .skip (reason = "normalized ontology contains Relationship, "
10- "which is not finalized yet. introduce this back when"
11- "Relationship feature is complete and we introduce"
12- "a Relationship object to the ontology that we can parse" )
10+ "which is not finalized yet. introduce this back when"
11+ "Relationship feature is complete and we introduce"
12+ "a Relationship object to the ontology that we can parse" )
1313def test_from_project_ontology (project ) -> None :
1414 o = OntologyBuilder .from_project (project )
1515 assert o .asdict () == project .ontology ().normalized
@@ -36,7 +36,8 @@ def test_deletes_an_ontology(client):
3636
3737
3838def test_cant_delete_an_ontology_with_project (client ):
39- project = client .create_project (name = "test project" , media_type = MediaType .Image )
39+ project = client .create_project (name = "test project" ,
40+ media_type = MediaType .Image )
4041 tool = client .upsert_feature_schema (point .asdict ())
4142 feature_schema_id = tool .normalized ['featureSchemaId' ]
4243 ontology = client .create_ontology_from_feature_schemas (
@@ -45,8 +46,11 @@ def test_cant_delete_an_ontology_with_project(client):
4546 media_type = MediaType .Image )
4647 project .setup_editor (ontology )
4748
48- with pytest .raises (Exception ,
49- match = "Failed to delete the ontology, message: Cannot delete an ontology connected to a project. The ontology is connected to projects: " + project .uid ):
49+ with pytest .raises (
50+ Exception ,
51+ match =
52+ "Failed to delete the ontology, message: Cannot delete an ontology connected to a project. The ontology is connected to projects: "
53+ + project .uid ):
5054 client .delete_unused_ontology (ontology .uid )
5155
5256 project .delete ()
@@ -55,60 +59,51 @@ def test_cant_delete_an_ontology_with_project(client):
5559
5660
5761def test_cant_delete_an_ontology_that_doesnt_exist (client ):
58- with pytest .raises (Exception ,
59- match = "Failed to delete the ontology, message: Failed to find ontology by id: doesntexist" ):
62+ with pytest .raises (
63+ Exception ,
64+ match =
65+ "Failed to delete the ontology, message: Failed to find ontology by id: doesntexist"
66+ ):
6067 client .delete_unused_ontology ("doesntexist" )
6168
6269
6370def test_inserts_a_feature_schema_at_given_position (client ):
64- tool1 = {
65- 'tool' : 'polygon' ,
66- 'name' : 'tool1' ,
67- 'color' : 'blue'
68- }
69- tool2 = {
70- 'tool' : 'polygon' ,
71- 'name' : 'tool2' ,
72- 'color' : 'blue'
73- }
74- ontology_normalized_json = {
75- "tools" : [tool1 , tool2 ],
76- "classifications" : []
77- }
71+ tool1 = {'tool' : 'polygon' , 'name' : 'tool1' , 'color' : 'blue' }
72+ tool2 = {'tool' : 'polygon' , 'name' : 'tool2' , 'color' : 'blue' }
73+ ontology_normalized_json = {"tools" : [tool1 , tool2 ], "classifications" : []}
7874 ontology = client .create_ontology (name = "ontology" ,
7975 normalized = ontology_normalized_json ,
8076 media_type = MediaType .Image )
8177 created_feature_schema = client .upsert_feature_schema (point .asdict ())
82- client .insert_feature_schema_into_ontology (created_feature_schema .normalized ['featureSchemaId' ], ontology .uid , 1 )
78+ client .insert_feature_schema_into_ontology (
79+ created_feature_schema .normalized ['featureSchemaId' ], ontology .uid , 1 )
8380 ontology = client .get_ontology (ontology .uid )
8481
85- assert ontology .normalized ['tools' ][1 ]['schemaNodeId' ] == created_feature_schema .normalized ['schemaNodeId' ]
82+ assert ontology .normalized ['tools' ][1 ][
83+ 'schemaNodeId' ] == created_feature_schema .normalized ['schemaNodeId' ]
8684
8785 client .delete_unused_ontology (ontology .uid )
8886
8987
9088def test_moves_already_added_feature_schema_in_ontology (client ):
91- tool1 = {
92- 'tool' : 'polygon' ,
93- 'name' : 'tool1' ,
94- 'color' : 'blue'
95- }
96- ontology_normalized_json = {
97- "tools" : [tool1 ],
98- "classifications" : []
99- }
89+ tool1 = {'tool' : 'polygon' , 'name' : 'tool1' , 'color' : 'blue' }
90+ ontology_normalized_json = {"tools" : [tool1 ], "classifications" : []}
10091 ontology = client .create_ontology (name = "ontology" ,
10192 normalized = ontology_normalized_json ,
10293 media_type = MediaType .Image )
10394 created_feature_schema = client .upsert_feature_schema (point .asdict ())
10495 feature_schema_id = created_feature_schema .normalized ['featureSchemaId' ]
105- client .insert_feature_schema_into_ontology (feature_schema_id , ontology .uid , 1 )
96+ client .insert_feature_schema_into_ontology (feature_schema_id , ontology .uid ,
97+ 1 )
10698 ontology = client .get_ontology (ontology .uid )
107- assert ontology .normalized ['tools' ][1 ]['schemaNodeId' ] == created_feature_schema .normalized ['schemaNodeId' ]
108- client .insert_feature_schema_into_ontology (feature_schema_id , ontology .uid , 0 )
99+ assert ontology .normalized ['tools' ][1 ][
100+ 'schemaNodeId' ] == created_feature_schema .normalized ['schemaNodeId' ]
101+ client .insert_feature_schema_into_ontology (feature_schema_id , ontology .uid ,
102+ 0 )
109103 ontology = client .get_ontology (ontology .uid )
110104
111- assert ontology .normalized ['tools' ][0 ]['schemaNodeId' ] == created_feature_schema .normalized ['schemaNodeId' ]
105+ assert ontology .normalized ['tools' ][0 ][
106+ 'schemaNodeId' ] == created_feature_schema .normalized ['schemaNodeId' ]
112107
113108 client .delete_unused_ontology (ontology .uid )
114109
0 commit comments