3
3
from labelbox .schema .search_filters import DateOperator , DateRange , DateRangeOperator , DateRangeValue , DateValue , IdOperator , OperationType , OrganizationFilter , WorkforceRequestedDateFilter , WorkforceRequestedDateRangeFilter , WorkspaceFilter
4
4
5
5
6
- def test_request_labeling_service_dashboard (
7
- rand_gen , offline_chat_evaluation_project , chat_evaluation_ontology ,
8
- offline_conversational_data_row ):
6
+ def test_request_labeling_service_dashboard (rand_gen ,
7
+ offline_chat_evaluation_project ,
8
+ chat_evaluation_ontology ,
9
+ offline_conversational_data_row ):
9
10
project = offline_chat_evaluation_project
10
11
project .connect_ontology (chat_evaluation_ontology )
11
12
@@ -30,50 +31,54 @@ def test_request_labeling_service_dashboard_filters(requested_labeling_service):
30
31
project , _ = requested_labeling_service
31
32
32
33
organization = project .client .get_organization ()
33
- org_filter = OrganizationFilter (
34
- operation = OperationType .Organization ,
35
- operator = IdOperator .Is ,
36
- values = [organization .uid ])
34
+ org_filter = OrganizationFilter (operation = OperationType .Organization ,
35
+ operator = IdOperator .Is ,
36
+ values = [organization .uid ])
37
37
38
38
labeling_service_dashboard = [
39
- ld for ld in project .client .get_labeling_service_dashboards (search_query = [org_filter ])
39
+ ld for ld in project .client .get_labeling_service_dashboards (
40
+ search_query = [org_filter ])
40
41
][0 ]
41
42
assert labeling_service_dashboard is not None
42
43
43
44
workforce_requested_filter_before = WorkforceRequestedDateFilter (
44
45
operation = OperationType .WorforceRequestedDate ,
45
46
value = DateValue (operator = DateOperator .GreaterThanOrEqual ,
46
- value = "2024-01-01" ))
47
- year_from_now = (datetime .now () + timedelta (days = 365 )). strftime ( "%Y-%m-%d" )
47
+ value = datetime . strptime ( "2024-01-01" , "%Y-%m-%d" )))
48
+ year_from_now = (datetime .now () + timedelta (days = 365 ))
48
49
workforce_requested_filter_after = WorkforceRequestedDateFilter (
49
50
operation = OperationType .WorforceRequestedDate ,
50
51
value = DateValue (operator = DateOperator .LessThanOrEqual ,
51
52
value = year_from_now ))
52
53
53
54
labeling_service_dashboard = [
54
- ld for ld in project .client .get_labeling_service_dashboards (search_query = [workforce_requested_filter_after , workforce_requested_filter_before ])
55
+ ld
56
+ for ld in project .client .get_labeling_service_dashboards (search_query = [
57
+ workforce_requested_filter_after , workforce_requested_filter_before
58
+ ])
55
59
][0 ]
56
60
assert labeling_service_dashboard is not None
57
61
58
62
workforce_date_range_filter = WorkforceRequestedDateRangeFilter (
59
63
operation = OperationType .WorforceRequestedDate ,
60
64
value = DateRangeValue (operator = DateRangeOperator .Between ,
61
- value = DateRange (min = "2024-01-01 " ,
62
- max = year_from_now )))
65
+ value = DateRange (min = "2024-01-01T00:00:00-0800 " ,
66
+ max = year_from_now )))
63
67
64
68
labeling_service_dashboard = [
65
- ld for ld in project .client .get_labeling_service_dashboards (search_query = [workforce_date_range_filter ])
69
+ ld for ld in project .client .get_labeling_service_dashboards (
70
+ search_query = [workforce_date_range_filter ])
66
71
][0 ]
67
72
assert labeling_service_dashboard is not None
68
73
69
74
# with non existing data
70
75
workspace_id = "clzzu4rme000008l42vnl4kre"
71
- workspace_filter = WorkspaceFilter (
72
- operation = OperationType .Workspace ,
73
- operator = IdOperator .Is ,
74
- values = [workspace_id ])
76
+ workspace_filter = WorkspaceFilter (operation = OperationType .Workspace ,
77
+ operator = IdOperator .Is ,
78
+ values = [workspace_id ])
75
79
labeling_service_dashboard = [
76
- ld for ld in project .client .get_labeling_service_dashboards (search_query = [workspace_filter ])
80
+ ld for ld in project .client .get_labeling_service_dashboards (
81
+ search_query = [workspace_filter ])
77
82
]
78
83
assert len (labeling_service_dashboard ) == 0
79
84
assert labeling_service_dashboard == []
0 commit comments