55import json
66import time
77
8-
9- def test_is_feature_schema_archived (client , ontology ):
8+ def test_feature_schema_is_not_archived (client , ontology ):
109 feature_schema_to_check = ontology .normalized ['tools' ][0 ]
1110 result = client .is_feature_schema_archived (
1211 ontology .uid , feature_schema_to_check ['featureSchemaId' ])
1312 assert result == False
1413
1514
15+ def test_feature_schema_is_archived (client , configured_project_with_label ):
16+ project , _ , _ , label = configured_project_with_label
17+ ontology = project .ontology ()
18+ feature_schema_id = ontology .normalized ['tools' ][0 ]['featureSchemaId' ]
19+ result = client .delete_feature_schema_from_ontology (ontology .uid ,
20+ feature_schema_id )
21+ assert result .archived == True and result .deleted == False
22+ assert client .is_feature_schema_archived (ontology .uid ,
23+ feature_schema_id ) == True
24+
25+
1626def test_is_feature_schema_archived_for_non_existing_feature_schema (
1727 client , ontology ):
1828 with pytest .raises (
@@ -21,7 +31,6 @@ def test_is_feature_schema_archived_for_non_existing_feature_schema(
2131 client .is_feature_schema_archived (ontology .uid ,
2232 'invalid-feature-schema-id' )
2333
24-
2534def test_is_feature_schema_archived_for_non_existing_ontology (client , ontology ):
2635 feature_schema_to_unarchive = ontology .normalized ['tools' ][0 ]
2736 with pytest .raises (
@@ -31,7 +40,6 @@ def test_is_feature_schema_archived_for_non_existing_ontology(client, ontology):
3140 client .is_feature_schema_archived (
3241 'invalid-ontology' , feature_schema_to_unarchive ['featureSchemaId' ])
3342
34-
3543def test_delete_tool_feature_from_ontology (client , ontology ):
3644 feature_schema_to_delete = ontology .normalized ['tools' ][0 ]
3745 assert len (ontology .normalized ['tools' ]) == 2
@@ -42,7 +50,6 @@ def test_delete_tool_feature_from_ontology(client, ontology):
4250 updatedOntology = client .get_ontology (ontology .uid )
4351 assert len (updatedOntology .normalized ['tools' ]) == 1
4452
45-
4653@pytest .mark .skip (reason = "normalized ontology contains Relationship, "
4754 "which is not finalized yet. introduce this back when"
4855 "Relationship feature is complete and we introduce"
@@ -51,14 +58,12 @@ def test_from_project_ontology(project) -> None:
5158 o = OntologyBuilder .from_project (project )
5259 assert o .asdict () == project .ontology ().normalized
5360
54-
5561point = Tool (
5662 tool = Tool .Type .POINT ,
5763 name = "name" ,
5864 color = "#ff0000" ,
5965)
6066
61-
6267def test_deletes_an_ontology (client ):
6368 tool = client .upsert_feature_schema (point .asdict ())
6469 feature_schema_id = tool .normalized ['featureSchemaId' ]
@@ -71,7 +76,6 @@ def test_deletes_an_ontology(client):
7176
7277 client .delete_unused_feature_schema (feature_schema_id )
7378
74-
7579def test_cant_delete_an_ontology_with_project (client ):
7680 project = client .create_project (name = "test project" ,
7781 media_type = MediaType .Image )
@@ -94,7 +98,6 @@ def test_cant_delete_an_ontology_with_project(client):
9498 client .delete_unused_ontology (ontology .uid )
9599 client .delete_unused_feature_schema (feature_schema_id )
96100
97-
98101def test_cant_delete_an_ontology_that_doesnt_exist (client ):
99102 with pytest .raises (
100103 Exception ,
@@ -103,7 +106,6 @@ def test_cant_delete_an_ontology_that_doesnt_exist(client):
103106 ):
104107 client .delete_unused_ontology ("doesntexist" )
105108
106-
107109def test_inserts_a_feature_schema_at_given_position (client ):
108110 tool1 = {'tool' : 'polygon' , 'name' : 'tool1' , 'color' : 'blue' }
109111 tool2 = {'tool' : 'polygon' , 'name' : 'tool2' , 'color' : 'blue' }
@@ -121,7 +123,6 @@ def test_inserts_a_feature_schema_at_given_position(client):
121123
122124 client .delete_unused_ontology (ontology .uid )
123125
124-
125126def test_moves_already_added_feature_schema_in_ontology (client ):
126127 tool1 = {'tool' : 'polygon' , 'name' : 'tool1' , 'color' : 'blue' }
127128 ontology_normalized_json = {"tools" : [tool1 ], "classifications" : []}
@@ -144,7 +145,6 @@ def test_moves_already_added_feature_schema_in_ontology(client):
144145
145146 client .delete_unused_ontology (ontology .uid )
146147
147-
148148def test_does_not_include_used_ontologies (client ):
149149 tool = client .upsert_feature_schema (point .asdict ())
150150 feature_schema_id = tool .normalized ['featureSchemaId' ]
@@ -163,14 +163,12 @@ def test_does_not_include_used_ontologies(client):
163163 client .delete_unused_ontology (ontology_with_project .uid )
164164 client .delete_unused_feature_schema (feature_schema_id )
165165
166-
167166def _get_attr_stringify_json (obj , attr ):
168167 value = getattr (obj , attr .name )
169168 if attr .field_type .name .lower () == "json" :
170169 return json .dumps (value , sort_keys = True )
171170 return value
172171
173-
174172def test_feature_schema_create_read (client , rand_gen ):
175173 name = f"test-root-schema-{ rand_gen (str )} "
176174 feature_schema_cat_normalized = {
@@ -199,7 +197,6 @@ def test_feature_schema_create_read(client, rand_gen):
199197 attr ) == _get_attr_stringify_json (
200198 queried_feature_schema , attr )
201199
202-
203200def test_ontology_create_read (client , rand_gen ):
204201 ontology_name = f"test-ontology-{ rand_gen (str )} "
205202 tool_name = f"test-ontology-tool-{ rand_gen (str )} "
0 commit comments