Skip to content

Commit 999e87c

Browse files
committed
add unit test for local file upload
1 parent d4c7983 commit 999e87c

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

tests/helpers.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@
2929
DatasetItem(TEST_IMG_URLS[2], "3"),
3030
DatasetItem(TEST_IMG_URLS[3], "4"),
3131
]
32+
33+
LOCAL_FILENAME = "tests/test_img.jpg"
3234
TEST_PREDS = [
3335
BoxPrediction("[Pytest Box Prediction 1]", 0, 0, 100, 100, "1"),
3436
BoxPrediction("[Pytest Box Prediction 2]", 0, 0, 100, 100, "2"),
@@ -60,7 +62,6 @@ def s3_sign(bucket, key):
6062
ExpiresIn=PRESIGN_EXPIRY_SECONDS,
6163
)
6264

63-
6465
def reference_id_from_url(url):
6566
return Path(url).name
6667

tests/test_dataset.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
TEST_SLICE_NAME,
55
TEST_DATASET_NAME,
66
TEST_IMG_URLS,
7+
LOCAL_FILENAME,
78
reference_id_from_url,
89
)
910

@@ -84,6 +85,19 @@ def check_is_expected_response(response):
8485
check_is_expected_response(response)
8586

8687

88+
def test_dataset_append_local(CLIENT, dataset):
89+
ds_items_local = [DatasetItem(image_location=LOCAL_FILENAME)]
90+
response = dataset.append(ds_items_local)
91+
assert isinstance(response, UploadResponse)
92+
resp_json = response.json()
93+
assert resp_json[DATASET_ID_KEY] == dataset.id
94+
assert resp_json[NEW_ITEMS] == 1
95+
assert resp_json[UPDATED_ITEMS] == 0
96+
assert resp_json[IGNORED_ITEMS] == 0
97+
assert resp_json[ERROR_ITEMS] == 0
98+
assert ERROR_PAYLOAD not in resp_json
99+
100+
87101
def test_dataset_list_autotags(CLIENT, dataset):
88102
# Creation
89103
# List of Autotags should be empty

0 commit comments

Comments
 (0)