1+ import time
12from pathlib import Path
23import json
34
45import superannotate as sa
5-
6- PROJECT_NAME = "Example Project test annotation add"
7- PROJECT_NAME_NOINIT = "Example Project test annotation add no init"
8- PROJECT_DESCRIPTION = "test vector"
9- PATH_TO_SAMPLE_PROJECT = Path ("./tests/sample_project_vector" )
6+ from .test_assign_images import safe_create_project
107
118
129def test_add_bbox (tmpdir ):
1310 tmpdir = Path (tmpdir )
1411
15- projects_found = sa .search_projects (PROJECT_NAME , return_metadata = True )
16- for pr in projects_found :
17- if pr ["name" ] == PROJECT_NAME :
18- sa .delete_project (pr )
12+ PROJECT_NAME = "Example Project test annotation add"
13+ PROJECT_DESCRIPTION = "test vector"
14+ PATH_TO_SAMPLE_PROJECT = Path ("./tests/sample_project_vector" )
1915
20- project = sa . create_project (PROJECT_NAME , PROJECT_DESCRIPTION , "Vector" )
16+ project = safe_create_project (PROJECT_NAME ,PROJECT_DESCRIPTION ,"Vector" )
2117 sa .upload_images_from_folder_to_project (
2218 PROJECT_NAME , PATH_TO_SAMPLE_PROJECT , annotation_status = "InProgress"
2319 )
@@ -40,8 +36,8 @@ def test_add_bbox(tmpdir):
4036 project , PATH_TO_SAMPLE_PROJECT
4137 )
4238
39+ time .sleep (2 )
4340 images = sa .search_images (project , "example_image_1" )
44-
4541 image_name = images [0 ]
4642 annotations = sa .get_image_annotations (project ,
4743 image_name )["annotation_json" ]
@@ -77,10 +73,10 @@ def test_add_bbox(tmpdir):
7773 project , image_name , "hey" , [100 , 100 ], "hovnatan@superannotate.com" ,
7874 True
7975 )
76+ time .sleep (2 )
8077 annotations_new = sa .get_image_annotations (project ,
8178 image_name )["annotation_json" ]
8279 json .dump (annotations_new , open (tmpdir / "new_anns.json" , "w" ))
83-
8480 assert len (annotations_new ["instances" ]) + len (
8581 annotations_new ["comments" ]
8682 ) == len (annotations ["instances" ]) + len (annotations ["comments" ]) + 8
@@ -101,19 +97,15 @@ def test_add_bbox(tmpdir):
10197
10298def test_add_bbox_noinit (tmpdir ):
10399 tmpdir = Path (tmpdir )
100+ PROJECT_NAME_NOINIT = "Example Project test annotation add no init"
101+ PROJECT_DESCRIPTION = "tt"
102+ PATH_TO_SAMPLE_PROJECT = Path ("./tests/sample_project_vector" )
104103
105- projects_found = sa .search_projects (
106- PROJECT_NAME_NOINIT , return_metadata = True
107- )
108- for pr in projects_found :
109- sa .delete_project (pr )
110-
111- project = sa .create_project (
112- PROJECT_NAME_NOINIT , PROJECT_DESCRIPTION , "Vector"
113- )
104+ project = safe_create_project (PROJECT_NAME_NOINIT ,PROJECT_DESCRIPTION ,"Vector" )
114105 sa .upload_images_from_folder_to_project (
115106 project , PATH_TO_SAMPLE_PROJECT , annotation_status = "InProgress"
116107 )
108+ time .sleep (2 )
117109 sa .create_annotation_classes_from_classes_json (
118110 project , PATH_TO_SAMPLE_PROJECT / "classes" / "classes.json"
119111 )
@@ -127,11 +119,13 @@ def test_add_bbox_noinit(tmpdir):
127119 sa .add_annotation_polygon_to_image (
128120 project , image_name , [100 , 100 , 500 , 500 , 200 , 300 ], "test_add"
129121 )
122+ time .sleep (2 )
130123 annotations_new = sa .get_image_annotations (project ,
131124 image_name )["annotation_json" ]
132125
133126 assert len (annotations_new ["instances" ]) == 2
134127 export = sa .prepare_export (project , include_fuse = True )
128+ time .sleep (2 )
135129 sa .download_export (project , export , tmpdir )
136130
137131 non_empty_annotations = 0
0 commit comments