Skip to content

Commit 076c7b7

Browse files
committed
Added integration test
1 parent 50fa1cb commit 076c7b7

File tree

3 files changed

+39
-6
lines changed

3 files changed

+39
-6
lines changed

labelbox/client.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -931,7 +931,6 @@ def delete_unused_ontology(self, ontology_id: str) -> None:
931931
Example:
932932
>>> client.delete_unused_ontology("cleabc1my012ioqvu5anyaabc")
933933
"""
934-
935934
endpoint = self.rest_endpoint + "/ontologies/" + urllib.parse.quote(
936935
ontology_id)
937936
response = requests.delete(
@@ -1635,10 +1634,10 @@ def delete_feature_schema_from_ontology(
16351634
logger.info(
16361635
'Feature schema was archived from the ontology because it had associated labels.'
16371636
)
1638-
return response_json
16391637
elif response_json['deleted'] == True:
16401638
logger.info(
16411639
'Feature schema was successfully removed from the ontology')
1640+
return response_json
16421641
else:
16431642
raise labelbox.exceptions.LabelboxError(
16441643
"Failed to remove feature schema from ontology, message: " +

tests/integration/conftest.py

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
from labelbox import Client
1313
from labelbox import LabelingFrontend
14-
from labelbox import OntologyBuilder, Tool, Option, Classification
14+
from labelbox import OntologyBuilder, Tool, Option, Classification, MediaType
1515
from labelbox.orm import query
1616
from labelbox.pagination import PaginatedCollection
1717
from labelbox.schema.annotation_import import LabelImport
@@ -524,4 +524,34 @@ def func(project):
524524
)
525525
time.sleep(2)
526526

527-
return func
527+
return func
528+
529+
@pytest.fixture
530+
def ontology(client):
531+
ontology_builder = OntologyBuilder(
532+
tools=[
533+
Tool(
534+
tool=Tool.Type.BBOX,
535+
name="Box 1",
536+
color="#ff0000"
537+
),
538+
Tool(
539+
tool=Tool.Type.BBOX,
540+
name="Box 2",
541+
color="#ff0000"
542+
)
543+
],
544+
classifications=[
545+
Classification(
546+
name="Root Class",
547+
class_type=Classification.Type.RADIO,
548+
options=[
549+
Option(value="1", label="Option 1"),
550+
Option(value="2", label="Option 2")
551+
]
552+
)
553+
]
554+
)
555+
ontology = client.create_ontology('Integration Test Ontology', ontology_builder.asdict(), MediaType.Image)
556+
yield ontology
557+
client.delete_unused_ontology(ontology.uid)

tests/integration/test_ontology.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,12 @@
55
import json
66
import time
77

8+
def test_delete_tool_feature_from_ontology(client, ontology):
9+
feature_schema_to_delete = ontology.normalized['tools'][0]
10+
result = client.delete_feature_schema_from_ontology(ontology.uid, feature_schema_to_delete['featureSchemaId'])
11+
assert result['deleted'] == True
12+
assert result['archived'] == False
13+
814

915
@pytest.mark.skip(reason="normalized ontology contains Relationship, "
1016
"which is not finalized yet. introduce this back when"
@@ -21,7 +27,6 @@ def test_from_project_ontology(project) -> None:
2127
color="#ff0000",
2228
)
2329

24-
2530
def test_deletes_an_ontology(client):
2631
tool = client.upsert_feature_schema(point.asdict())
2732
feature_schema_id = tool.normalized['featureSchemaId']
@@ -34,7 +39,6 @@ def test_deletes_an_ontology(client):
3439

3540
client.delete_unused_feature_schema(feature_schema_id)
3641

37-
3842
def test_cant_delete_an_ontology_with_project(client):
3943
project = client.create_project(name="test project",
4044
media_type=MediaType.Image)

0 commit comments

Comments
 (0)