Skip to content

Commit d0a9a40

Browse files
committed
Cleanup duplicate images test
1 parent 3ac0ba9 commit d0a9a40

File tree

3 files changed

+18
-15
lines changed

3 files changed

+18
-15
lines changed

superannotate/db/projects.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -442,6 +442,10 @@ def upload_images_from_folder_to_project(
442442
"""Uploads all images with given extensions from folder_path to the project.
443443
Sets status of all the uploaded images to set_status if it is not None.
444444
445+
If an image with existing name already exists in the project it won't be uploaded,
446+
and its path will be appended to the third member of return value of this
447+
function.
448+
445449
:param project: project name or metadata of the project to upload images_to
446450
:type project: str or dict
447451
:param folder_path: from which folder to upload the images
@@ -464,8 +468,8 @@ def upload_images_from_folder_to_project(
464468
Can be either "compressed" or "original". If None then the default value in project settings will be used.
465469
:type image_quality_in_editor: str
466470
467-
:return: uploaded and not-uploaded images' filepaths
468-
:rtype: tuple of list of strs
471+
:return: uploaded, could-not-upload, existing-images filepaths
472+
:rtype: tuple (3 members) of list of strs
469473
"""
470474
if not isinstance(project, dict):
471475
project = get_project_metadata_bare(project)
Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
from pathlib import Path
2-
import time
32

43
import pytest
54

@@ -17,26 +16,26 @@ def test_duplicate_upload_images(tmpdir):
1716

1817
project = sa.create_project(PROJECT_NAME_VECTOR, "test", "Vector")
1918

20-
uploads = sa.upload_images_from_folder_to_project(
19+
uploaded, could_not_upload, existing_images = sa.upload_images_from_folder_to_project(
2120
project, "./tests/sample_project_vector"
2221
)
2322

24-
assert len(uploads[0]) == 4
25-
assert len(uploads[1]) == 0
26-
assert len(uploads[2]) == 0
23+
assert len(uploaded) == 4
24+
assert len(could_not_upload) == 0
25+
assert len(existing_images) == 0
2726

28-
uploads = sa.upload_images_to_project(
27+
uploaded, could_not_upload, existing_images = sa.upload_images_to_project(
2928
project, ["./tests/sample_project_vector/dd.jpg"]
3029
)
3130

32-
assert len(uploads[0]) == 0
33-
assert len(uploads[1]) == 1
34-
assert len(uploads[2]) == 0
31+
assert len(uploaded) == 0
32+
assert len(could_not_upload) == 1
33+
assert len(existing_images) == 0
3534

36-
uploads = sa.upload_images_from_folder_to_project(
35+
uploaded, could_not_upload, existing_images = sa.upload_images_from_folder_to_project(
3736
project, "./tests/sample_project_vector"
3837
)
3938

40-
assert len(uploads[0]) == 0
41-
assert len(uploads[1]) == 0
42-
assert len(uploads[2]) == 4
39+
assert len(uploaded) == 0
40+
assert len(could_not_upload) == 0
41+
assert len(existing_images) == 4

0 commit comments

Comments
 (0)