@@ -17,6 +17,17 @@ class TestMoveItems(BaseTestCase):
1717 FOLDER_2 = "folder_2"
1818 CSV_PATH = "data_set/attach_urls.csv"
1919
20+ Attachment = [
21+ {
22+ "url" : "https://drive.google.com/uc?export=download&id=1vwfCpTzcjxoEA4hhDxqapPOVvLVeS7ZS" ,
23+ "name" : IMAGE_NAME ,
24+ },
25+ {
26+ "url" : "https://drive.google.com/uc?export=download&id=1vwfCpTzcjxoEA4hhDxqapPOVvLVeS7Zw" ,
27+ "name" : IMAGE_NAME_2 ,
28+ },
29+ ]
30+
2031 @property
2132 def scv_path (self ):
2233 return os .path .join (Path (__file__ ).parent .parent .parent , self .CSV_PATH )
@@ -46,21 +57,11 @@ def test_move_items_from_folder(self):
4657 assert len (sa .search_items (f"{ self .PROJECT_NAME } /{ self .FOLDER_2 } " )) == 7
4758 assert len (sa .search_items (f"{ self .PROJECT_NAME } /{ self .FOLDER_1 } " )) == 0
4859
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+ def test_move_items_from_folder_with_replace (self ):
6061 sa .create_folder (self .PROJECT_NAME , self .FOLDER_1 )
6162 sa .create_folder (self .PROJECT_NAME , self .FOLDER_2 )
6263 uploaded , _ , _ = sa .attach_items (
63- f"{ self .PROJECT_NAME } /{ self .FOLDER_1 } " , attachment
64+ f"{ self .PROJECT_NAME } /{ self .FOLDER_1 } " , self . Attachment
6465 )
6566 assert len (uploaded ) == 2
6667 sa .set_approval_statuses (
@@ -75,7 +76,7 @@ def test_move_items_from_folder_with_replace_strategy(self):
7576 )
7677
7778 uploaded_2 , _ , _ = sa .attach_items (
78- f"{ self .PROJECT_NAME } /{ self .FOLDER_2 } " , attachment
79+ f"{ self .PROJECT_NAME } /{ self .FOLDER_2 } " , self . Attachment
7980 )
8081 assert len (uploaded_2 ) == 2
8182 folder_2_items = sa .search_items (f"{ self .PROJECT_NAME } /{ self .FOLDER_2 } " )
@@ -96,3 +97,64 @@ def test_move_items_from_folder_with_replace_strategy(self):
9697 folder_2_items = sa .search_items (f"{ self .PROJECT_NAME } /{ self .FOLDER_2 } " )
9798 assert folder_2_items [0 ]["annotation_status" ] == "Completed"
9899 assert folder_2_items [0 ]["approval_status" ] == "Approved"
100+
101+ def test_move_items_from_folder_with_replace_annotations_only (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+ folder_2_items = sa .search_items (f"{ self .PROJECT_NAME } /{ self .FOLDER_2 } " )
124+ assert folder_2_items [0 ]["annotation_status" ] == "NotStarted"
125+ assert not folder_2_items [0 ]["approval_status" ]
126+
127+ skipped_items = sa .move_items (
128+ f"{ self .PROJECT_NAME } /{ self .FOLDER_1 } " ,
129+ f"{ self .PROJECT_NAME } /{ self .FOLDER_2 } " ,
130+ duplicate_strategy = "replace_annotations_only" ,
131+ )
132+ assert len (skipped_items ) == 0
133+ folder_1_items = sa .search_items (f"{ self .PROJECT_NAME } /{ self .FOLDER_1 } " )
134+ folder_2_items = sa .search_items (f"{ self .PROJECT_NAME } /{ self .FOLDER_2 } " )
135+ assert len (folder_1_items ) == 0
136+ assert len (folder_2_items ) == 2
137+
138+ folder_2_items = sa .search_items (f"{ self .PROJECT_NAME } /{ self .FOLDER_2 } " )
139+ assert folder_2_items [0 ]["annotation_status" ] == "NotStarted"
140+ assert not folder_2_items [0 ]["approval_status" ]
141+
142+ def test_move_items_from_folder_with_skip (self ):
143+ sa .create_folder (self .PROJECT_NAME , self .FOLDER_1 )
144+ sa .create_folder (self .PROJECT_NAME , self .FOLDER_2 )
145+ uploaded , _ , _ = sa .attach_items (
146+ f"{ self .PROJECT_NAME } /{ self .FOLDER_1 } " , self .Attachment
147+ )
148+ assert len (uploaded ) == 2
149+
150+ uploaded_2 , _ , _ = sa .attach_items (
151+ f"{ self .PROJECT_NAME } /{ self .FOLDER_2 } " , self .Attachment
152+ )
153+ assert len (uploaded_2 ) == 2
154+
155+ skipped_items = sa .move_items (
156+ f"{ self .PROJECT_NAME } /{ self .FOLDER_1 } " ,
157+ f"{ self .PROJECT_NAME } /{ self .FOLDER_2 } " ,
158+ duplicate_strategy = "skip" ,
159+ )
160+ assert len (skipped_items ) == 2
0 commit comments