11import json
22import os
3+ import glob
34import tempfile
45from pathlib import Path
56
@@ -70,4 +71,28 @@ def test_download_empty_annotations_from_folders(self):
7071 )
7172 with tempfile .TemporaryDirectory () as temp_dir :
7273 annotations_path = sa .download_annotations (f"{ self .PROJECT_NAME } " , temp_dir )
73- self .assertEqual (len (os .listdir (annotations_path )), 1 )
74+ self .assertEqual (len (os .listdir (annotations_path )), 1 )
75+
76+ @pytest .mark .flaky (reruns = 3 )
77+ def test_download_annotations_from_folders (self ):
78+ sa .create_folder (self .PROJECT_NAME , self .FOLDER_NAME )
79+ sa .create_folder (self .PROJECT_NAME , self .FOLDER_NAME_2 )
80+ sa .create_annotation_classes_from_classes_json (
81+ self .PROJECT_NAME , f"{ self .folder_path } /classes/classes.json"
82+ )
83+ sa .attach_items (
84+ f'{ self .PROJECT_NAME } /{ self .FOLDER_NAME } ' ,
85+ [{"name" : f"example_image_{ i } .jpg" , "url" : f"url_{ i } " } for i in range (1 , 5 )] # noqa
86+ )
87+ sa .attach_items (
88+ self .PROJECT_NAME ,
89+ [{"name" : f"example_image_{ i } .jpg" , "url" : f"url_{ i } " } for i in range (1 , 19 )] # noqa
90+ )
91+ sa .attach_items (
92+ f'{ self .PROJECT_NAME } /{ self .FOLDER_NAME_2 } ' ,
93+ [{"name" : f"example_image_{ i } .jpg" , "url" : f"url_{ i } " } for i in range (1 , 10 )] # noqa
94+ )
95+ with tempfile .TemporaryDirectory () as temp_dir :
96+ annotations_path = sa .download_annotations (self .PROJECT_NAME , temp_dir , recursive = True )
97+ count = len ([i for i in glob .iglob (annotations_path + '**/**' , recursive = True )])
98+ assert count == 31 + 5 # folder names and classes
0 commit comments