Skip to content

Commit e2a4290

Browse files
author
Val Brodsky
committed
Fix tests
1 parent 15551ca commit e2a4290

File tree

2 files changed

+18
-43
lines changed

2 files changed

+18
-43
lines changed

libs/labelbox/src/labelbox/schema/labeling_service_dashboard.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -200,8 +200,8 @@ def convert_boost_data(cls, data):
200200

201201
return data
202202

203-
def __repr__(self):
204-
row = self.dict()
203+
def dict(self, *args, **kwargs):
204+
row = super().dict(*args, **kwargs)
205205
row.pop('client')
206206
row['tasks_completed'] = self.tasks_completed
207207
row['tasks_remaining'] = self.tasks_remaining

libs/labelbox/tests/integration/test_labeling_dashboard.py

Lines changed: 16 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -4,37 +4,22 @@
44
from labelbox.schema.ontology_kind import EditorTaskType
55
from labelbox.schema.media_type import MediaType
66
from labelbox.schema.search_filters import IntegerValue, RangeOperatorWithSingleValue, DateRange, RangeOperatorWithValue, DateRangeValue, DateValue, IdOperator, OperationType, OrganizationFilter, TaskCompletedCountFilter, WorkforceRequestedDateFilter, WorkforceRequestedDateRangeFilter, WorkspaceFilter, TaskRemainingCountFilter
7-
import pytest
87

98

109
def test_request_labeling_service_dashboard(requested_labeling_service):
1110
project, _ = requested_labeling_service
1211

1312
labeling_service_dashboard = project.labeling_service_dashboard()
14-
assert labeling_service_dashboard.status == LabelingServiceStatus.Missing
13+
assert labeling_service_dashboard.status == LabelingServiceStatus.Requested
1514
assert labeling_service_dashboard.tasks_completed == 0
1615
assert labeling_service_dashboard.tasks_remaining == 0
1716
assert labeling_service_dashboard.media_type == MediaType.Conversational
18-
assert labeling_service_dashboard.editor_task_type == EditorTaskType.OfflineModelChatEvaluation
19-
assert labeling_service_dashboard.service_type == "Offline chat evaluation"
17+
assert labeling_service_dashboard.editor_task_type == EditorTaskType.ModelChatEvaluation
18+
assert labeling_service_dashboard.service_type == "Live chat evaluation"
2019

21-
labeling_service_dashboard = [
22-
ld for ld in project.client.get_labeling_service_dashboards()
23-
][0]
24-
assert labeling_service_dashboard.status == LabelingServiceStatus.Missing
25-
assert labeling_service_dashboard.tasks_completed == 0
26-
assert labeling_service_dashboard.tasks_remaining == 0
27-
28-
29-
def test_request_labeling_service_dashboard_not_started(
30-
offline_chat_evaluation_project):
31-
project = offline_chat_evaluation_project
32-
33-
with pytest.raises(ResourceNotFoundError) as e:
34-
project.labeling_service_dashboard()
35-
36-
with pytest.raises(ResourceNotFoundError) as e:
37-
[ld for ld in project.client.get_labeling_service_dashboards()][0]
20+
labeling_service_dashboard = project.client.get_labeling_service_dashboards(
21+
).get_one()
22+
assert labeling_service_dashboard
3823

3924

4025
def test_request_labeling_service_dashboard_filters(requested_labeling_service):
@@ -45,10 +30,8 @@ def test_request_labeling_service_dashboard_filters(requested_labeling_service):
4530
operator=IdOperator.Is,
4631
values=[organization.uid])
4732

48-
labeling_service_dashboard = [
49-
ld for ld in project.client.get_labeling_service_dashboards(
50-
search_query=[org_filter])
51-
][0]
33+
labeling_service_dashboard = project.client.get_labeling_service_dashboards(
34+
search_query=[org_filter]).get_one()
5235
assert labeling_service_dashboard is not None
5336

5437
workforce_requested_filter_before = WorkforceRequestedDateFilter(
@@ -62,12 +45,10 @@ def test_request_labeling_service_dashboard_filters(requested_labeling_service):
6245
value=DateValue(operator=RangeOperatorWithSingleValue.LessThanOrEqual,
6346
value=year_from_now))
6447

65-
labeling_service_dashboard = [
66-
ld
67-
for ld in project.client.get_labeling_service_dashboards(search_query=[
48+
labeling_service_dashboard = project.client.get_labeling_service_dashboards(
49+
search_query=[
6850
workforce_requested_filter_after, workforce_requested_filter_before
69-
])
70-
][0]
51+
]).get_one()
7152
assert labeling_service_dashboard is not None
7253

7354
workforce_date_range_filter = WorkforceRequestedDateRangeFilter(
@@ -76,10 +57,8 @@ def test_request_labeling_service_dashboard_filters(requested_labeling_service):
7657
value=DateRange(min="2024-01-01T00:00:00-0800",
7758
max=year_from_now)))
7859

79-
labeling_service_dashboard = [
80-
ld for ld in project.client.get_labeling_service_dashboards(
81-
search_query=[workforce_date_range_filter])
82-
][0]
60+
labeling_service_dashboard = project.client.get_labeling_service_dashboards(
61+
search_query=[workforce_date_range_filter]).get_one()
8362
assert labeling_service_dashboard is not None
8463

8564
# with non existing data
@@ -93,9 +72,6 @@ def test_request_labeling_service_dashboard_filters(requested_labeling_service):
9372
]
9473
assert len(labeling_service_dashboard) == 0
9574
assert labeling_service_dashboard == []
96-
labeling_service_dashboard = project.client.get_labeling_service_dashboards(
97-
).get_one()
98-
assert labeling_service_dashboard
9975

10076
task_done_count_filter = TaskCompletedCountFilter(
10177
operation=OperationType.TaskCompletedCount,
@@ -106,8 +82,7 @@ def test_request_labeling_service_dashboard_filters(requested_labeling_service):
10682
value=IntegerValue(
10783
operator=RangeOperatorWithSingleValue.GreaterThanOrEqual, value=0))
10884

109-
labeling_service_dashboard = [
110-
ld for ld in project.client.get_labeling_service_dashboards(
111-
search_query=[task_done_count_filter, task_remaining_count_filter])
112-
][0]
85+
labeling_service_dashboard = project.client.get_labeling_service_dashboards(
86+
search_query=[task_done_count_filter, task_remaining_count_filter
87+
]).get_one()
11388
assert labeling_service_dashboard is not None

0 commit comments

Comments
 (0)