@@ -18,6 +18,16 @@ class TestCopyItems(BaseTestCase):
1818 FOLDER_1 = "folder_1"
1919 FOLDER_2 = "folder_2"
2020 CSV_PATH = "data_set/attach_urls.csv"
21+ Attachment = [
22+ {
23+ "url" : "https://drive.google.com/uc?export=download&id=1vwfCpTzcjxoEA4hhDxqapPOVvLVeS7ZS" ,
24+ "name" : IMAGE_NAME ,
25+ },
26+ {
27+ "url" : "https://drive.google.com/uc?export=download&id=1vwfCpTzcjxoEA4hhDxqapPOVvLVeS7Zw" ,
28+ "name" : IMAGE_NAME_2 ,
29+ },
30+ ]
2131
2232 @property
2333 def scv_path (self ):
@@ -69,12 +79,7 @@ def test_skipped_count(self):
6979 def test_copy_items_wrong_items_list (self ):
7080 uploaded , _ , _ = sa .attach_items (
7181 self .PROJECT_NAME ,
72- [
73- {
74- "url" : "https://drive.google.com/uc?export=download&id=1vwfCpTzcjxoEA4hhDxqapPOVvLVeS7ZS" ,
75- "name" : self .IMAGE_NAME ,
76- }
77- ],
82+ self .Attachment ,
7883 )
7984 sa .set_approval_statuses (self .PROJECT_NAME , "Approved" , items = [self .IMAGE_NAME ])
8085 sa .set_annotation_statuses (
@@ -92,3 +97,47 @@ def test_copy_items_wrong_items_list(self):
9297 assert items [0 ]["annotation_status" ] == "Completed"
9398 assert items [0 ]["approval_status" ] == "Approved"
9499 assert Counter (skipped_items ) == Counter (["as" , "asd" ])
100+
101+ def test_copy_duplicated_items_without_data_with_replace_strategy (self ):
102+ sa .create_folder (self .PROJECT_NAME , self .FOLDER_1 )
103+ sa .create_folder (self .PROJECT_NAME , self .FOLDER_2 )
104+ uploaded , _ , _ = sa .attach_items (
105+ f"{ self .PROJECT_NAME } /{ self .FOLDER_1 } " , self .Attachment
106+ )
107+ assert len (uploaded ) == 2
108+ sa .set_approval_statuses (
109+ f"{ self .PROJECT_NAME } /{ self .FOLDER_1 } " ,
110+ "Approved" ,
111+ items = [self .IMAGE_NAME , self .IMAGE_NAME_2 ],
112+ )
113+ sa .set_annotation_statuses (
114+ f"{ self .PROJECT_NAME } /{ self .FOLDER_1 } " ,
115+ "Completed" ,
116+ items = [self .IMAGE_NAME , self .IMAGE_NAME_2 ],
117+ )
118+
119+ uploaded_2 , _ , _ = sa .attach_items (
120+ f"{ self .PROJECT_NAME } /{ self .FOLDER_2 } " , self .Attachment
121+ )
122+ assert len (uploaded_2 ) == 2
123+
124+ with self .assertLogs ("sa" , level = "WARNING" ) as cm :
125+ skipped_items = sa .copy_items (
126+ f"{ self .PROJECT_NAME } /{ self .FOLDER_1 } " ,
127+ f"{ self .PROJECT_NAME } /{ self .FOLDER_2 } " ,
128+ include_annotations = False ,
129+ duplicate_strategy = "replace" ,
130+ )
131+ assert (
132+ "WARNING:sa:Copy operation continuing without annotations and metadata"
133+ " due to include_annotations=False." == cm .output [0 ]
134+ )
135+ assert len (skipped_items ) == 2
136+ folder_1_items = sa .search_items (f"{ self .PROJECT_NAME } /{ self .FOLDER_1 } " )
137+ folder_2_items = sa .search_items (f"{ self .PROJECT_NAME } /{ self .FOLDER_2 } " )
138+ assert len (folder_1_items ) == 2
139+ assert len (folder_2_items ) == 2
140+
141+ folder_2_items = sa .search_items (f"{ self .PROJECT_NAME } /{ self .FOLDER_2 } " )
142+ assert folder_2_items [0 ]["annotation_status" ] == "NotStarted"
143+ assert not folder_2_items [0 ]["approval_status" ]
0 commit comments