Skip to content

Commit 6bc05f9

Browse files
author
Val Brodsky
committed
Fix tests
1 parent cc37fd8 commit 6bc05f9

File tree

8 files changed

+31
-56
lines changed

8 files changed

+31
-56
lines changed

libs/labelbox/src/labelbox/project_validation.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ class _CoreProjectInput(BaseModel):
4040
def validate_fields(self):
4141
if (
4242
self.auto_audit_percentage is not None
43-
and self.auto_audit_number_of_labels is not None
43+
or self.auto_audit_number_of_labels is not None
4444
):
4545
raise ValueError(
4646
"quality_modes must be set instead of auto_audit_percentage or auto_audit_number_of_labels."
@@ -67,9 +67,8 @@ def validate_fields(self):
6767
)
6868
elif self.quality_modes == {QualityMode.Consensus}:
6969
self._set_quality_mode_attributes(
70-
data,
71-
CONSENSUS_AUTO_AUDIT_NUMBER_OF_LABELS,
72-
CONSENSUS_AUTO_AUDIT_PERCENTAGE,
70+
number_of_labels=CONSENSUS_AUTO_AUDIT_NUMBER_OF_LABELS,
71+
percentage=CONSENSUS_AUTO_AUDIT_PERCENTAGE,
7372
is_consensus_enabled=True,
7473
)
7574

libs/labelbox/tests/conftest.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -453,7 +453,7 @@ def project(client, rand_gen):
453453
def consensus_project(client, rand_gen):
454454
project = client.create_project(
455455
name=rand_gen(str),
456-
quality_mode=QualityMode.Consensus,
456+
quality_modes={QualityMode.Consensus},
457457
media_type=MediaType.Image,
458458
)
459459
yield project

libs/labelbox/tests/data/export/conftest.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -285,6 +285,23 @@ def configured_project_without_data_rows(
285285
teardown_helpers.teardown_project_labels_ontology_feature_schemas(project)
286286

287287

288+
@pytest.fixture
289+
def configured_video_project_without_data_rows(
290+
client, ontology, rand_gen, teardown_helpers
291+
):
292+
project = client.create_project(
293+
name=rand_gen(str),
294+
description=rand_gen(str),
295+
media_type=MediaType.Video,
296+
)
297+
editor = list(
298+
client.get_labeling_frontends(where=LabelingFrontend.name == "editor")
299+
)[0]
300+
project.setup(editor, ontology)
301+
yield project
302+
teardown_helpers.teardown_project_labels_ontology_feature_schemas(project)
303+
304+
288305
@pytest.fixture
289306
def model_run_with_data_rows(
290307
client,

libs/labelbox/tests/data/export/streamable/test_export_video_streamable.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,13 @@ def org_id(self, client):
2121
def test_export(
2222
self,
2323
client,
24-
configured_project_without_data_rows,
24+
configured_video_project_without_data_rows,
2525
video_data,
2626
video_data_row,
2727
bbox_video_annotation_objects,
2828
rand_gen,
2929
):
30-
project = configured_project_without_data_rows
30+
project = configured_video_project_without_data_rows
3131
project_id = project.uid
3232
labels = []
3333

libs/labelbox/tests/integration/test_client_errors.py

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -81,34 +81,6 @@ def test_network_error(client):
8181
client.create_project(name="Project name", media_type=MediaType.Image)
8282

8383

84-
def test_invalid_attribute_error(
85-
client,
86-
rand_gen,
87-
):
88-
# Creation
89-
with pytest.raises(lbox.exceptions.InvalidAttributeError) as excinfo:
90-
client.create_project(
91-
name="Name", invalid_field="Whatever", media_type=MediaType.Image
92-
)
93-
assert excinfo.value.db_object_type == Project
94-
assert excinfo.value.field == "invalid_field"
95-
96-
# Update
97-
project = client.create_project(
98-
name=rand_gen(str), media_type=MediaType.Image
99-
)
100-
with pytest.raises(lbox.exceptions.InvalidAttributeError) as excinfo:
101-
project.update(invalid_field="Whatever")
102-
assert excinfo.value.db_object_type == Project
103-
assert excinfo.value.field == "invalid_field"
104-
105-
# Top-level-fetch
106-
with pytest.raises(lbox.exceptions.InvalidAttributeError) as excinfo:
107-
client.get_projects(where=User.email == "email")
108-
assert excinfo.value.db_object_type == Project
109-
assert excinfo.value.field == {User.email}
110-
111-
11284
@pytest.mark.skip("timeouts cause failure before rate limit")
11385
def test_api_limit_error(client):
11486
def get(arg):

libs/labelbox/tests/integration/test_filtering.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
import pytest
22
from lbox.exceptions import InvalidQueryError
3-
from libs.labelbox.src.labelbox.schema.media_type import MediaType
43

54
from labelbox import Project
6-
from labelbox.schema import media_type
5+
from labelbox.schema.media_type import MediaType
76

87

98
@pytest.fixture
Lines changed: 6 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,12 @@
1+
from os import name
2+
13
import pytest
4+
from pydantic import ValidationError
25

36
from labelbox.schema import media_type
47
from labelbox.schema.media_type import MediaType
58

69

7-
def test_project_dataset(client, rand_gen):
8-
with pytest.raises(
9-
ValueError,
10-
match="Dataset queue mode is deprecated. Please prefer Batch queue mode.",
11-
):
12-
client.create_project(
13-
name=rand_gen(str),
14-
media_type=MediaType.Image,
15-
)
16-
17-
1810
def test_project_auto_audit_parameters(client, rand_gen):
1911
with pytest.raises(
2012
ValueError,
@@ -27,7 +19,7 @@ def test_project_auto_audit_parameters(client, rand_gen):
2719
)
2820

2921
with pytest.raises(
30-
ValueError,
22+
ValidationError,
3123
match="quality_modes must be set instead of auto_audit_percentage or auto_audit_number_of_labels.",
3224
):
3325
client.create_project(
@@ -39,11 +31,6 @@ def test_project_auto_audit_parameters(client, rand_gen):
3931

4032
def test_project_name_parameter(client, rand_gen):
4133
with pytest.raises(
42-
ValueError, match="project name must be a valid string."
43-
):
44-
client.create_project()
45-
46-
with pytest.raises(
47-
ValueError, match="project name must be a valid string."
34+
ValidationError, match="project name must be a valid string"
4835
):
49-
client.create_project(name=" ")
36+
client.create_project(name=" ", media_type=MediaType.Image)

libs/labelbox/tests/unit/schema/test_user_group.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ def group_project():
3232
project_values = defaultdict(lambda: None)
3333
project_values["id"] = "project_id"
3434
project_values["name"] = "Test Project"
35+
project_values["queueMode"] = QueueMode.Batch.value
3536
project_values["editorTaskType"] = EditorTaskType.Missing.value
3637
project_values["mediaType"] = MediaType.Image.value
3738
return Project(MagicMock(Client), project_values)

0 commit comments

Comments
 (0)