Skip to content

Commit 7c31d9f

Browse files
Narek MkhitaryanNarek Mkhitaryan
authored andcommitted
updated copy/move test cases
1 parent b7e9a82 commit 7c31d9f

File tree

5 files changed

+63
-4
lines changed

5 files changed

+63
-4
lines changed

src/superannotate/lib/core/serviceproviders.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,7 @@ def copy_move_multiple(
297297
item_names: List[str],
298298
duplicate_strategy: Literal["skip", "replace", "replace_annotations_only"],
299299
operation: Literal["copy", "move"],
300-
include_annotations: bool = False,
300+
include_annotations: bool = True,
301301
include_pin: bool = False,
302302
) -> ServiceResponse:
303303
raise NotImplementedError

src/superannotate/lib/infrastructure/controller.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -544,7 +544,7 @@ def copy_multiple(
544544
to_folder: FolderEntity,
545545
duplicate_strategy: Literal["skip", "replace", "replace_annotations_only"],
546546
item_names: List[str] = None,
547-
include_annotations: bool = False,
547+
include_annotations: bool = True,
548548
):
549549
if project.type == ProjectType.PIXEL:
550550
use_case = usecases.CopyItems(

src/superannotate/lib/infrastructure/services/item.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ def copy_move_multiple(
122122
item_names: List[str],
123123
duplicate_strategy: Literal["skip", "replace", "replace_annotations_only"],
124124
operation: Literal["copy", "move"],
125-
include_annotations: bool = False,
125+
include_annotations: bool = True,
126126
include_pin: bool = False,
127127
):
128128
"""
@@ -153,7 +153,7 @@ def await_copy_move(
153153
self, project: entities.ProjectEntity, poll_id: int, items_count
154154
):
155155
try:
156-
await_time = items_count * 0.3
156+
await_time = 60 + items_count * 0.3 # time for waiting backend processing
157157
timeout_start = time.time()
158158
while time.time() < timeout_start + await_time:
159159
response = self.client.request(

tests/integration/items/test_copy_items.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ class TestCopyItems(BaseTestCase):
1414
PROJECT_DESCRIPTION = "TestCopyItemsVector"
1515
PROJECT_TYPE = "Vector"
1616
IMAGE_NAME = "test_image"
17+
IMAGE_NAME_2 = "test_image_2"
1718
FOLDER_1 = "folder_1"
1819
FOLDER_2 = "folder_2"
1920
CSV_PATH = "data_set/attach_urls.csv"
@@ -75,6 +76,10 @@ def test_copy_items_wrong_items_list(self):
7576
}
7677
],
7778
)
79+
sa.set_approval_statuses(self.PROJECT_NAME, "Approved", items=[self.IMAGE_NAME])
80+
sa.set_annotation_statuses(
81+
self.PROJECT_NAME, "Completed", items=[self.IMAGE_NAME]
82+
)
7883
sa.create_folder(self.PROJECT_NAME, self.FOLDER_1)
7984
skipped_items = sa.copy_items(
8085
self.PROJECT_NAME,
@@ -84,4 +89,6 @@ def test_copy_items_wrong_items_list(self):
8489
items = sa.search_items(f"{self.PROJECT_NAME}/{self.FOLDER_1}")
8590
assert len(items) == 1
8691
assert items[0]["name"] == self.IMAGE_NAME
92+
assert items[0]["annotation_status"] == "Completed"
93+
assert items[0]["approval_status"] == "Approved"
8794
assert Counter(skipped_items) == Counter(["as", "asd"])

tests/integration/items/test_move_items.py

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ class TestMoveItems(BaseTestCase):
1212
PROJECT_DESCRIPTION = "TestCopyItemsVector"
1313
PROJECT_TYPE = "Vector"
1414
IMAGE_NAME = "test_image"
15+
IMAGE_NAME_2 = "test_image_2"
1516
FOLDER_1 = "folder_1"
1617
FOLDER_2 = "folder_2"
1718
CSV_PATH = "data_set/attach_urls.csv"
@@ -44,3 +45,54 @@ def test_move_items_from_folder(self):
4445
assert len(skipped_items) == 0
4546
assert len(sa.search_items(f"{self.PROJECT_NAME}/{self.FOLDER_2}")) == 7
4647
assert len(sa.search_items(f"{self.PROJECT_NAME}/{self.FOLDER_1}")) == 0
48+
49+
def test_move_items_from_folder_with_replace_strategy(self):
50+
attachment = [
51+
{
52+
"url": "https://drive.google.com/uc?export=download&id=1vwfCpTzcjxoEA4hhDxqapPOVvLVeS7ZS",
53+
"name": self.IMAGE_NAME,
54+
},
55+
{
56+
"url": "https://drive.google.com/uc?export=download&id=1vwfCpTzcjxoEA4hhDxqapPOVvLVeS7Zw",
57+
"name": self.IMAGE_NAME_2,
58+
},
59+
]
60+
sa.create_folder(self.PROJECT_NAME, self.FOLDER_1)
61+
sa.create_folder(self.PROJECT_NAME, self.FOLDER_2)
62+
uploaded, _, _ = sa.attach_items(
63+
f"{self.PROJECT_NAME}/{self.FOLDER_1}", attachment
64+
)
65+
assert len(uploaded) == 2
66+
sa.set_approval_statuses(
67+
f"{self.PROJECT_NAME}/{self.FOLDER_1}",
68+
"Approved",
69+
items=[self.IMAGE_NAME, self.IMAGE_NAME_2],
70+
)
71+
sa.set_annotation_statuses(
72+
f"{self.PROJECT_NAME}/{self.FOLDER_1}",
73+
"Completed",
74+
items=[self.IMAGE_NAME, self.IMAGE_NAME_2],
75+
)
76+
77+
uploaded_2, _, _ = sa.attach_items(
78+
f"{self.PROJECT_NAME}/{self.FOLDER_2}", attachment
79+
)
80+
assert len(uploaded_2) == 2
81+
folder_2_items = sa.search_items(f"{self.PROJECT_NAME}/{self.FOLDER_2}")
82+
assert folder_2_items[0]["annotation_status"] == "NotStarted"
83+
assert not folder_2_items[0]["approval_status"]
84+
85+
skipped_items = sa.move_items(
86+
f"{self.PROJECT_NAME}/{self.FOLDER_1}",
87+
f"{self.PROJECT_NAME}/{self.FOLDER_2}",
88+
duplicate_strategy="replace",
89+
)
90+
assert len(skipped_items) == 0
91+
folder_1_items = sa.search_items(f"{self.PROJECT_NAME}/{self.FOLDER_1}")
92+
folder_2_items = sa.search_items(f"{self.PROJECT_NAME}/{self.FOLDER_2}")
93+
assert len(folder_1_items) == 0
94+
assert len(folder_2_items) == 2
95+
96+
folder_2_items = sa.search_items(f"{self.PROJECT_NAME}/{self.FOLDER_2}")
97+
assert folder_2_items[0]["annotation_status"] == "Completed"
98+
assert folder_2_items[0]["approval_status"] == "Approved"

0 commit comments

Comments
 (0)