@@ -271,130 +271,3 @@ def test_creating_activating_new_ml_backend(
271
271
def test_delete_annotations (business_client , configured_project ):
272
272
business_client .delete (f'/api/projects/{ configured_project .id } /annotations/' )
273
273
assert not Annotation .objects .filter (task__project = configured_project .id ).exists ()
274
-
275
-
276
- # --- TaskAPI ---
277
-
278
-
279
- @pytest .mark .parametrize (
280
- 'response, status_code' ,
281
- [
282
- # status OK
283
- (
284
- {
285
- 'annotations' : [],
286
- 'predictions' : [],
287
- 'drafts' : [],
288
- 'data' : {'text' : 'text B' , 'meta_info' : 'meta info B' },
289
- 'meta' : {},
290
- 'created_at' : '' ,
291
- 'updated_at' : '' ,
292
- 'updated_by' : [],
293
- 'is_labeled' : False ,
294
- 'project' : 0 ,
295
- 'overlap' : 1 ,
296
- 'file_upload' : None ,
297
- 'annotations_ids' : '' ,
298
- 'annotations_results' : '' ,
299
- 'annotators' : [],
300
- 'completed_at' : None ,
301
- 'predictions_model_versions' : '' ,
302
- 'draft_exists' : False ,
303
- 'predictions_results' : '' ,
304
- 'predictions_score' : None ,
305
- 'total_annotations' : 0 ,
306
- 'total_predictions' : 0 ,
307
- 'avg_lead_time' : None ,
308
- 'cancelled_annotations' : 0 ,
309
- 'inner_id' : 0 ,
310
- 'storage_filename' : None ,
311
- 'comment_authors' : [],
312
- 'comment_count' : 0 ,
313
- 'last_comment_updated_at' : None ,
314
- 'unresolved_comment_count' : 0 ,
315
- },
316
- 200 ,
317
- )
318
- ],
319
- )
320
- @pytest .mark .django_db
321
- def test_get_task (client_and_token , configured_project , response , status_code ):
322
- client , token = client_and_token
323
- task = configured_project .tasks .order_by ('-id' ).all ()[0 ]
324
- response ['project' ] = configured_project .id
325
- response ['created_at' ] = task .created_at .isoformat ().replace ('+00:00' , 'Z' )
326
- response ['updated_at' ] = task .updated_at .isoformat ().replace ('+00:00' , 'Z' )
327
- response ['id' ] = task .id
328
- r = client .get (
329
- f'/api/tasks/{ task .id } /' , content_type = 'application/json' , headers = {'Authorization' : f'Token { token } ' }
330
- )
331
- assert r .status_code == status_code
332
- if response :
333
- assert r .json () == response
334
-
335
-
336
- @pytest .mark .parametrize (
337
- 'payload, response, status_code' ,
338
- [
339
- # status OK
340
- (
341
- {
342
- 'annotations' : [],
343
- 'predictions' : [],
344
- 'data' : {'text' : 'TEST1' , 'meta_info' : 'TEST2' },
345
- 'meta' : {},
346
- 'created_at' : '' ,
347
- 'updated_at' : '' ,
348
- 'updated_by' : None ,
349
- 'is_labeled' : False ,
350
- 'project' : 0 ,
351
- 'file_upload' : None ,
352
- },
353
- {
354
- 'id' : 0 ,
355
- 'annotations' : [],
356
- 'predictions' : [],
357
- 'data' : {'text' : 'TEST1' , 'meta_info' : 'TEST2' },
358
- 'meta' : {},
359
- 'created_at' : '' ,
360
- 'updated_at' : '' ,
361
- 'updated_by' : None ,
362
- 'is_labeled' : False ,
363
- 'project' : 0 ,
364
- 'overlap' : 1 ,
365
- 'file_upload' : None ,
366
- 'inner_id' : 1 ,
367
- 'comment_authors' : [],
368
- 'comment_count' : 0 ,
369
- 'last_comment_updated_at' : None ,
370
- 'unresolved_comment_count' : 0 ,
371
- },
372
- 200 ,
373
- )
374
- ],
375
- )
376
- @pytest .mark .django_db
377
- def test_patch_task (client_and_token , configured_project , payload , response , status_code ):
378
- client , token = client_and_token
379
- task = configured_project .tasks .order_by ('-updated_at' ).all ()[0 ]
380
- payload ['project' ] = configured_project .id
381
-
382
- r = client .patch (
383
- f'/api/tasks/{ task .id } /' ,
384
- data = json .dumps (payload ),
385
- content_type = 'application/json' ,
386
- headers = {'Authorization' : f'Token { token } ' },
387
- )
388
-
389
- task = configured_project .tasks .order_by ('-updated_at' ).all ()[0 ] # call DB again after update
390
- response ['project' ] = configured_project .id
391
- response ['created_at' ] = task .created_at .isoformat ().replace ('+00:00' , 'Z' )
392
- response ['updated_at' ] = task .updated_at .isoformat ().replace ('+00:00' , 'Z' )
393
- response ['id' ] = task .id
394
- response ['total_annotations' ] = 0
395
- response ['cancelled_annotations' ] = 0
396
- response ['total_predictions' ] = 0
397
-
398
- assert r .status_code == status_code
399
- if response :
400
- assert r .json () == response
0 commit comments