Skip to content

Commit c858798

Browse files
authored
Remove message field check from test_dataset tests (#291)
* Remove message field check from test_dataset_append_async_with_1_bad_url * Use partial checks in more places in test_dataset
1 parent cac5559 commit c858798

File tree

1 file changed

+10
-32
lines changed

1 file changed

+10
-32
lines changed

tests/test_dataset.py

Lines changed: 10 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
TEST_MULTICATEGORY_ANNOTATIONS,
3838
TEST_POLYGON_ANNOTATIONS,
3939
TEST_SEGMENTATION_ANNOTATIONS,
40+
assert_partial_equality,
4041
reference_id_from_url,
4142
)
4243

@@ -294,26 +295,14 @@ def test_dataset_append_async(dataset: Dataset):
294295
job = dataset.append(make_dataset_items(), asynchronous=True)
295296
job.sleep_until_complete()
296297
status = job.status()
297-
status["message"]["PayloadUrl"] = ""
298-
print(status)
299-
assert status == {
298+
expected = {
300299
"job_id": job.job_id,
301300
"status": "Completed",
302-
"message": {
303-
"PayloadUrl": "",
304-
"image_upload_step": {"errored": 0, "pending": 0, "completed": 5},
305-
"started_image_processing": f"Dataset: {dataset.id}, Job: {job.job_id}",
306-
"ingest_to_reupload_queue": {
307-
"epoch": 1,
308-
"total": 5,
309-
"datasetId": f"{dataset.id}",
310-
"processed": 5,
311-
},
312-
},
313301
"job_progress": "1.00",
314302
"completed_steps": 5,
315303
"total_steps": 5,
316304
}
305+
assert_partial_equality(expected, status)
317306

318307

319308
def test_dataset_append_async_with_local_path(dataset: Dataset):
@@ -341,22 +330,8 @@ def test_dataset_append_async_with_1_bad_url(dataset: Dataset):
341330
assert status["job_progress"] == "0.80"
342331
assert status["completed_steps"] == 4
343332
assert status["total_steps"] == 5
344-
assert status["message"] == {
345-
"PayloadUrl": "",
346-
"image_upload_step": {"errored": 1, "pending": 0, "completed": 4},
347-
"ingest_to_reupload_queue": {
348-
"epoch": 1,
349-
"total": 5,
350-
"datasetId": f"{dataset.id}",
351-
"processed": 5,
352-
},
353-
"started_image_processing": f"Dataset: {dataset.id}, Job: {job.job_id}",
354-
}
355333
# The error is fairly detailed and subject to change. What's important is we surface which URLs failed.
356-
assert (
357-
'Failure when processing the image "https://looks.ok.but.is.not.accessible"'
358-
in str(job.errors())
359-
)
334+
assert '"https://looks.ok.but.is.not.accessible"' in str(job.errors())
360335

361336

362337
def test_dataset_list_autotags(CLIENT, dataset):
@@ -398,7 +373,8 @@ def test_annotate_async(dataset: Dataset):
398373
asynchronous=True,
399374
)
400375
job.sleep_until_complete()
401-
assert job.status() == {
376+
status = job.status()
377+
expected = {
402378
"job_id": job.job_id,
403379
"status": "Completed",
404380
"message": {
@@ -420,6 +396,7 @@ def test_annotate_async(dataset: Dataset):
420396
"completed_steps": 5,
421397
"total_steps": 5,
422398
}
399+
assert_partial_equality(expected, status)
423400

424401

425402
@pytest.mark.integration
@@ -439,8 +416,8 @@ def test_annotate_async_with_error(dataset: Dataset):
439416
asynchronous=True,
440417
)
441418
job.sleep_until_complete()
442-
443-
assert job.status() == {
419+
status = job.status()
420+
expected = {
444421
"job_id": job.job_id,
445422
"status": "Completed",
446423
"message": {
@@ -462,6 +439,7 @@ def test_annotate_async_with_error(dataset: Dataset):
462439
"completed_steps": 5,
463440
"total_steps": 5,
464441
}
442+
assert_partial_equality(expected, status)
465443

466444
assert "Item with id fake_garbage doesn" in str(job.errors())
467445

0 commit comments

Comments
 (0)