Skip to content

Commit 45a1359

Browse files
committed
Fix tests
1 parent 9c19ea7 commit 45a1359

File tree

9 files changed

+10
-126
lines changed

9 files changed

+10
-126
lines changed

src/superannotate/lib/core/usecases/annotations.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -580,26 +580,25 @@ def get_existing_name_item_mapping(
580580

581581
@property
582582
def annotation_upload_data(self) -> UploadAnnotationAuthData:
583-
CHUNK_SIZE=UploadAnnotationsFromFolderUseCase.CHUNK_SIZE_PATHS
583+
CHUNK_SIZE = UploadAnnotationsFromFolderUseCase.CHUNK_SIZE_PATHS
584584

585585
if self._annotation_upload_data:
586586
return self._annotation_upload_data
587587

588-
images={}
588+
images = {}
589589
for i in range(0, len(self._item_ids), CHUNK_SIZE):
590590
tmp = self._service_provider.get_annotation_upload_data(
591591
project=self._project,
592592
folder=self._folder,
593-
item_ids=self._item_ids[i:i+CHUNK_SIZE],
594-
593+
item_ids=self._item_ids[i : i + CHUNK_SIZE],
595594
)
596595
if not tmp.ok:
597596
raise AppException(tmp.errors)
598597
else:
599598
images.update(tmp.data.images)
600599

601-
self._annotation_upload_data=tmp.data
602-
self._annotation_upload_data.images=images
600+
self._annotation_upload_data = tmp.data
601+
self._annotation_upload_data.images = images
603602

604603
return self._annotation_upload_data
605604

src/superannotate/lib/core/usecases/images.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1046,7 +1046,7 @@ def filter_paths(self, paths: List[str]):
10461046
raise AppException(response.error)
10471047
image_list.extend([image.name for image in response.data])
10481048

1049-
image_list=set(image_list)
1049+
image_list = set(image_list)
10501050
images_to_upload = []
10511051

10521052
for path in filtered_paths:

tests/integration/annotations/test_annotations_upload_status_change.py

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -38,18 +38,6 @@ def test_upload_annotations_from_folder_to_project__upload_status(self, reporter
3838
sa.get_item_metadata(self.PROJECT_NAME, self.IMAGE_NAME)["annotation_status"]
3939
)
4040

41-
@pytest.mark.flaky(reruns=2)
42-
@patch("lib.infrastructure.controller.Reporter")
43-
def test_upload_preannotations_from_folder_to_project__upload_status(self, reporter):
44-
reporter_mock = MagicMock()
45-
reporter.return_value = reporter_mock
46-
sa.upload_image_to_project(self.PROJECT_NAME, join(self.folder_path, self.IMAGE_NAME))
47-
sa.upload_preannotations_from_folder_to_project(self.PROJECT_NAME, self.folder_path)
48-
self.assertEqual(
49-
constances.AnnotationStatus.IN_PROGRESS.name,
50-
sa.get_item_metadata(self.PROJECT_NAME, self.IMAGE_NAME)["annotation_status"]
51-
)
52-
5341
@pytest.mark.flaky(reruns=2)
5442
@patch("lib.infrastructure.controller.Reporter")
5543
def test_upload_image_annotations__upload_status(self, reporter):

tests/integration/annotations/test_missing_annotation_upload.py

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -45,23 +45,3 @@ def test_missing_annotation_upload(self):
4545
]
4646
)
4747
)
48-
49-
def test_missing_pre_annotation_upload(self):
50-
51-
sa.upload_images_from_folder_to_project(
52-
self.PROJECT_NAME, self.folder_path, annotation_status="NotStarted"
53-
)
54-
sa.create_annotation_classes_from_classes_json(
55-
self.PROJECT_NAME, f"{self.folder_path}/classes/classes.json"
56-
)
57-
(
58-
uploaded,
59-
could_not_upload,
60-
missing_images,
61-
) = sa.upload_preannotations_from_folder_to_project(
62-
self.PROJECT_NAME, self.folder_path
63-
)
64-
self.assertEqual(len(uploaded), 3)
65-
self.assertEqual(len(could_not_upload), 0)
66-
self.assertEqual(len(missing_images), 1)
67-

tests/integration/test_basic_images.py

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -94,18 +94,6 @@ def folder_path(self):
9494
def classes_json_path(self):
9595
return f"{self.folder_path}/classes/classes.json"
9696

97-
def test_vector_annotations_with_tag_folder_upload_preannotation(self):
98-
sa.upload_images_from_folder_to_project(
99-
self.PROJECT_NAME, self.folder_path, annotation_status="InProgress"
100-
)
101-
sa.create_annotation_classes_from_classes_json(
102-
self.PROJECT_NAME, self.classes_json_path
103-
)
104-
uploaded_annotations, _, _ = sa.upload_preannotations_from_folder_to_project(
105-
self.PROJECT_NAME, self.folder_path
106-
)
107-
self.assertEqual(len(uploaded_annotations), 1)
108-
10997

11098
class TestPixelImages(BaseTestCase):
11199
PROJECT_NAME = "sample_project_pixel"

tests/integration/test_cli.py

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -127,19 +127,6 @@ def test_upload_export(self):
127127
self.assertEqual(len(list(test_dir.glob("*.jpg"))), 0)
128128
self.assertEqual(len(list(test_dir.glob("*.png"))), 0)
129129

130-
def test_vector_pre_annotation_folder_upload_download_cli(self):
131-
self._create_project()
132-
133-
sa.create_annotation_classes_from_classes_json(
134-
self.PROJECT_NAME, f"{self.vector_folder_path}/classes/classes.json"
135-
)
136-
self.safe_run(self._cli.upload_images, project=self.PROJECT_NAME, folder=str(self.convertor_data_path),
137-
extensions="jpg",
138-
set_annotation_status="QualityCheck")
139-
self.safe_run(self._cli.upload_preannotations, project=self.PROJECT_NAME, folder=str(self.convertor_data_path),
140-
format="COCO",
141-
dataset_name="instances_test")
142-
143130
def test_vector_annotation_folder_upload_download_cli(self):
144131
self._create_project()
145132
sa.create_annotation_classes_from_classes_json(

tests/integration/test_depricated_functions_document.py

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -83,10 +83,6 @@ def test_deprecated_functions(self):
8383
sa.download_image_annotations(self.PROJECT_NAME, self.UPLOAD_IMAGE_NAME, "./")
8484
except AppException as e:
8585
self.assertIn(self.EXCEPTION_MESSAGE, str(e))
86-
try:
87-
sa.copy_image(self.PROJECT_NAME, self.UPLOAD_IMAGE_NAME, self.PROJECT_NAME_2)
88-
except AppException as e:
89-
self.assertIn(self.EXCEPTION_MESSAGE, str(e))
9086
try:
9187
sa.upload_images_to_project(self.PROJECT_NAME, [self.image_path, ])
9288
except AppException as e:
@@ -103,10 +99,6 @@ def test_deprecated_functions(self):
10399
sa.set_project_workflow(self.PROJECT_NAME, [{}])
104100
except AppException as e:
105101
self.assertIn(self.EXCEPTION_MESSAGE, str(e))
106-
try:
107-
sa.upload_preannotations_from_folder_to_project(self.PROJECT_NAME, self.folder_path)
108-
except AppException as e:
109-
self.assertIn(self.EXCEPTION_MESSAGE, str(e))
110102
try:
111103
sa.add_annotation_point_to_image(self.PROJECT_NAME, self.UPLOAD_IMAGE_NAME, [1, 2], "some class")
112104
except AppException as e:

tests/integration/test_depricated_functions_video.py

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -76,10 +76,6 @@ def test_deprecated_functions(self):
7676
sa.download_image_annotations(self.PROJECT_NAME, self.UPLOAD_IMAGE_NAME, "./")
7777
except AppException as e:
7878
self.assertIn(self.EXCEPTION_MESSAGE, str(e))
79-
try:
80-
sa.copy_image(self.PROJECT_NAME, self.UPLOAD_IMAGE_NAME, self.PROJECT_NAME_2)
81-
except AppException as e:
82-
self.assertIn(self.EXCEPTION_MESSAGE, str(e))
8379
try:
8480
sa.upload_images_to_project(self.PROJECT_NAME, [self.image_path, ])
8581
except AppException as e:
@@ -96,10 +92,6 @@ def test_deprecated_functions(self):
9692
sa.set_project_workflow(self.PROJECT_NAME, [{}])
9793
except AppException as e:
9894
self.assertIn(self.EXCEPTION_MESSAGE, str(e))
99-
try:
100-
sa.upload_preannotations_from_folder_to_project(self.PROJECT_NAME, self.folder_path)
101-
except AppException as e:
102-
self.assertIn(self.EXCEPTION_MESSAGE, str(e))
10395
try:
10496
sa.get_project_workflow(self.PROJECT_NAME)
10597
except AppException as e:
Lines changed: 4 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,19 @@
11
import os
2-
from unittest.mock import patch
32
from os.path import dirname
3+
from unittest.mock import patch
44

5-
from src.superannotate import SAClient
6-
sa = SAClient()
75
from src.superannotate import AppException
6+
from src.superannotate import SAClient
87
from src.superannotate.lib.core import UPLOAD_FOLDER_LIMIT_ERROR_MESSAGE
98
from src.superannotate.lib.core import UPLOAD_PROJECT_LIMIT_ERROR_MESSAGE
109
from src.superannotate.lib.core import UPLOAD_USER_LIMIT_ERROR_MESSAGE
11-
from src.superannotate.lib.core import COPY_FOLDER_LIMIT_ERROR_MESSAGE
12-
from src.superannotate.lib.core import COPY_PROJECT_LIMIT_ERROR_MESSAGE
13-
from src.superannotate.lib.core import COPY_SUPER_LIMIT_ERROR_MESSAGE
1410
from tests.integration.base import BaseTestCase
1511
from tests.moks.limitatoins import folder_limit_response
1612
from tests.moks.limitatoins import project_limit_response
1713
from tests.moks.limitatoins import user_limit_response
1814

15+
sa = SAClient()
16+
1917

2018
class TestLimitsUploadImagesFromFolderToProject(BaseTestCase):
2119
PROJECT_NAME = "TestLimitsUploadImagesFromFolderToProject"
@@ -49,43 +47,3 @@ def test_user_limitations(self, *_):
4947
_, _, __ = sa.upload_images_from_folder_to_project(
5048
project=self._project["name"], folder_path=self.folder_path
5149
)
52-
53-
54-
class TestLimitsCopyImage(BaseTestCase):
55-
PROJECT_NAME = "TestLimitsCopyImage"
56-
PROJECT_DESCRIPTION = "Desc"
57-
PROJECT_TYPE = "Vector"
58-
TEST_FOLDER_PTH = "data_set"
59-
TEST_FOLDER_PATH = "data_set/sample_project_vector"
60-
EXAMPLE_IMAGE_1 = "example_image_1.jpg"
61-
62-
@property
63-
def folder_path(self):
64-
return os.path.join(dirname(dirname(__file__)), self.TEST_FOLDER_PATH)
65-
66-
def test_folder_limitations(self):
67-
sa.upload_image_to_project(self._project["name"], os.path.join(self.folder_path, self.EXAMPLE_IMAGE_1))
68-
sa.create_folder(self._project["name"], self._project["name"])
69-
with patch("lib.infrastructure.serviceprovider.ServiceProvider.get_limitations") as limit_response:
70-
limit_response.return_value = folder_limit_response
71-
with self.assertRaisesRegexp(AppException, COPY_FOLDER_LIMIT_ERROR_MESSAGE):
72-
_, _, __ = sa.copy_image(
73-
self._project["name"], self.folder_path, f"{self.PROJECT_NAME}/{self.PROJECT_NAME}")
74-
75-
def test_project_limitations(self, ):
76-
sa.upload_image_to_project(self._project["name"], os.path.join(self.folder_path, self.EXAMPLE_IMAGE_1))
77-
sa.create_folder(self._project["name"], self._project["name"])
78-
with patch("lib.infrastructure.serviceprovider.ServiceProvider.get_limitations") as limit_response:
79-
limit_response.return_value = project_limit_response
80-
with self.assertRaisesRegexp(AppException, COPY_PROJECT_LIMIT_ERROR_MESSAGE):
81-
_, _, __ = sa.copy_image(
82-
self._project["name"], self.folder_path, f"{self.PROJECT_NAME}/{self.PROJECT_NAME}")
83-
84-
def test_user_limitations(self, ):
85-
sa.upload_image_to_project(self._project["name"], os.path.join(self.folder_path, self.EXAMPLE_IMAGE_1))
86-
sa.create_folder(self._project["name"], self._project["name"])
87-
with patch("lib.infrastructure.serviceprovider.ServiceProvider.get_limitations") as limit_response:
88-
limit_response.return_value = user_limit_response
89-
with self.assertRaisesRegexp(AppException, COPY_SUPER_LIMIT_ERROR_MESSAGE):
90-
_, _, __ = sa.copy_image(
91-
self._project["name"], self.folder_path, f"{self.PROJECT_NAME}/{self.PROJECT_NAME}")

0 commit comments

Comments
 (0)