@@ -116,3 +116,52 @@ def test_cancel():
116
116
# raises a scaleexception, because test tasks complete instantly
117
117
with pytest .raises (scaleapi .ScaleException ):
118
118
task .cancel ()
119
+
120
+
121
+ def test_task_retrieval ():
122
+ task = client .create_annotation_task (
123
+ callback_url = 'http://www.example.com/callback' ,
124
+ instruction = 'Draw a box around each **baby cow** and **big cow**' ,
125
+ attachment_type = 'image' ,
126
+ attachment = 'http://i.imgur.com/v4cBreD.jpg' ,
127
+ objects_to_annotate = ['baby cow' , 'big cow' ],
128
+ with_labels = True )
129
+
130
+ task2 = client .fetch_task (task .id )
131
+ assert task .status == 'pending'
132
+ assert task2 .status == 'completed'
133
+ assert task2 .id == task .id
134
+ assert task2 .callback_url == task .callback_url
135
+ assert task2 .instruction == task .instruction
136
+ assert task2 .attachment_type == task .attachment_type
137
+ assert task2 .attachment == task .attachment
138
+ assert task2 .objects_to_annotate == task .objects_to_annotate
139
+ assert task2 .with_labels == task .with_labels
140
+ assert task2 .metadata == task .metadata
141
+ assert task2 .type == task .type
142
+ assert task2 .created_at == task .created_at
143
+
144
+
145
+ def test_task_retrieval_fail ():
146
+ with pytest .raises (scaleapi .ScaleException ):
147
+ client .fetch_task ('fake_id_qwertyuiop' )
148
+
149
+
150
+ def test_tasks ():
151
+ tasks = []
152
+ for i in range (3 ):
153
+ tasks .append (client .create_annotation_task (
154
+ callback_url = 'http://www.example.com/callback' ,
155
+ instruction = 'Draw a box around each **baby cow** and **big cow**' ,
156
+ attachment_type = 'image' ,
157
+ attachment = 'http://i.imgur.com/v4cBreD.jpg' ,
158
+ objects_to_annotate = ['baby cow' , 'big cow' ],
159
+ with_labels = True ))
160
+ task_ids = {task .id for task in tasks }
161
+ for task in client .tasks (limit = 3 ):
162
+ assert task .id in task_ids
163
+
164
+
165
+ def test_tasks_invalid ():
166
+ with pytest .raises (scaleapi .ScaleException ):
167
+ client .tasks (bogus = 0 )
0 commit comments