11import os
22from os .path import dirname
33import pytest
4-
54import src .superannotate as sa
65from tests .integration .base import BaseTestCase
7-
6+ import tempfile
7+ import json
8+ from os .path import join
89
910class TestRecursiveFolderPixel (BaseTestCase ):
1011 PROJECT_NAME = "test_recursive_pixel"
1112 PROJECT_DESCRIPTION = "Desc"
1213 PROJECT_TYPE = "Pixel"
1314 S3_FOLDER_PATH = "sample_project_pixel"
1415 TEST_FOLDER_PATH = "data_set/sample_project_pixel"
16+ IMAGE_NAME = "example_image_1.jpg"
1517
1618 @property
1719 def folder_path (self ):
@@ -26,3 +28,16 @@ def test_recursive_annotation_upload_pixel(self):
2628 from_s3_bucket = "superannotate-python-sdk-test" ,
2729 recursive_subfolders = False )
2830 self .assertEqual (len (uploaded_annotations ), 3 )
31+
32+ @pytest .mark .flaky (reruns = 2 )
33+ def test_annotation_upload_pixel (self ):
34+ sa .upload_images_from_folder_to_project (self .PROJECT_NAME , self .folder_path )
35+ sa .upload_annotations_from_folder_to_project (self .PROJECT_NAME , self .folder_path )
36+ with tempfile .TemporaryDirectory () as tmp_dir :
37+ sa .download_image_annotations (self .PROJECT_NAME , self .IMAGE_NAME , tmp_dir )
38+ origin_annotation = json .load (open (f"{ self .folder_path } /{ self .IMAGE_NAME } ___pixel.json" ))
39+ annotation = json .load (open (join (tmp_dir , f"{ self .IMAGE_NAME } ___pixel.json" )))
40+ self .assertEqual (
41+ [i ["attributes" ] for i in annotation ["instances" ]],
42+ [i ["attributes" ] for i in origin_annotation ["instances" ]]
43+ )
0 commit comments