Skip to content

Commit 1677269

Browse files
committed
MODEL-1489: Rewrote tests
1 parent 0c80185 commit 1677269

File tree

3 files changed

+35
-24
lines changed

3 files changed

+35
-24
lines changed

libs/labelbox/tests/data/annotation_import/test_data_types.py

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,8 @@
1-
import datetime
2-
from labelbox.schema.label import Label
31
import pytest
4-
import uuid
52

63
from labelbox.data.annotation_types.data import (
74
AudioData,
85
ConversationData,
9-
DicomData,
106
DocumentData,
117
HTMLData,
128
ImageData,
@@ -15,11 +11,8 @@
1511
from labelbox.data.serialization import NDJsonConverter
1612
from labelbox.data.annotation_types.data.video import VideoData
1713

18-
import labelbox as lb
1914
import labelbox.types as lb_types
2015
from labelbox.schema.media_type import MediaType
21-
from labelbox.schema.annotation_import import AnnotationImportState
22-
from labelbox import Project, Client
2316

2417
# Unit test for label based on data type.
2518
# TODO: Dicom removed it is unstable when you deserialize and serialize on label import. If we intend to keep this library this needs add generic data types tests work with this data type.
@@ -84,20 +77,3 @@ def test_data_row_type_by_global_key(
8477

8578
assert data_label.data.global_key == label.data.global_key
8679
assert label.annotations == data_label.annotations
87-
88-
89-
@pytest.mark.parametrize("_, data_class, annotations", test_params)
90-
def test_import_label_annotations_with_is_benchmark_reference_flag(
91-
data_class, annotations, _):
92-
labels = [
93-
lb_types.Label(data=data_class(uid=str(uuid.uuid4()),
94-
url="http://test.com"),
95-
annotations=annotations,
96-
is_benchmark_reference=True)
97-
]
98-
serialized_annotations = get_annotation_comparison_dicts_from_labels(labels)
99-
100-
assert len(serialized_annotations) == len(annotations)
101-
for serialized_annotation in serialized_annotations:
102-
assert serialized_annotation["isBenchmarkReferenceLabel"]
103-

libs/labelbox/tests/data/serialization/ndjson/test_conversation.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,3 +101,18 @@ def test_conversation_entity_import(filename: str):
101101
res = list(NDJsonConverter.deserialize(data))
102102
res = list(NDJsonConverter.serialize(res))
103103
assert res == data
104+
105+
106+
def test_benchmark_reference_label_flag():
107+
label = lb_types.Label(data=lb_types.ConversationData(global_key='my_global_key'),
108+
annotations=[
109+
lb_types.ClassificationAnnotation(
110+
name='free_text',
111+
message_id="0",
112+
value=lb_types.Text(answer="sample text"))
113+
],
114+
is_benchmark_reference=True
115+
)
116+
117+
res = list(NDJsonConverter.serialize([label]))
118+
assert res[0]["isBenchmarkReferenceLabel"]

libs/labelbox/tests/data/serialization/ndjson/test_rectangle.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,3 +85,23 @@ def test_rectangle_mixed_start_end_points():
8585

8686
res = list(NDJsonConverter.deserialize(res))
8787
assert res == [label]
88+
89+
90+
def test_benchmark_reference_label_flag():
91+
bbox = lb_types.ObjectAnnotation(
92+
name="bbox",
93+
value=lb_types.Rectangle(
94+
start=lb_types.Point(x=81, y=28),
95+
end=lb_types.Point(x=38, y=69),
96+
),
97+
extra={"uuid": "c1be3a57-597e-48cb-8d8d-a852665f9e72"}
98+
)
99+
100+
label = lb_types.Label(
101+
data={"uid":DATAROW_ID},
102+
annotations=[bbox],
103+
is_benchmark_reference=True
104+
)
105+
106+
res = list(NDJsonConverter.serialize([label]))
107+
assert res[0]["isBenchmarkReferenceLabel"]

0 commit comments

Comments
 (0)