From 195962559829d64249f7251900e172b310087821 Mon Sep 17 00:00:00 2001 From: Vaghinak Basentsyan Date: Thu, 23 Mar 2023 10:27:34 +0400 Subject: [PATCH] Classes tests updates --- .../annotations/test_annotation_class_new.py | 45 --- .../annotations/test_annotation_classes.py | 52 --- .../classes/test_create_annotation_class.py | 343 ++++++++++-------- ...te_annotation_classes_from_classes_json.py | 208 +++++++++++ .../classes/test_create_bed_handling.py | 32 -- .../classes/test_tag_annotation_classes.py | 146 -------- .../test_classes_serialization.py | 0 7 files changed, 394 insertions(+), 432 deletions(-) delete mode 100644 tests/integration/annotations/test_annotation_class_new.py delete mode 100644 tests/integration/annotations/test_annotation_classes.py create mode 100644 tests/integration/classes/test_create_annotation_classes_from_classes_json.py delete mode 100644 tests/integration/classes/test_create_bed_handling.py delete mode 100644 tests/integration/classes/test_tag_annotation_classes.py rename tests/{integration/classes => unit}/test_classes_serialization.py (100%) diff --git a/tests/integration/annotations/test_annotation_class_new.py b/tests/integration/annotations/test_annotation_class_new.py deleted file mode 100644 index 7bcea9400..000000000 --- a/tests/integration/annotations/test_annotation_class_new.py +++ /dev/null @@ -1,45 +0,0 @@ -import os -from pathlib import Path - -from src.superannotate import SAClient -from tests.integration.base import BaseTestCase - -sa = SAClient() - - -class TestAnnotationClasses(BaseTestCase): - PROJECT_NAME = "test_annotation_class_new" - PROJECT_DESCRIPTION = "desc" - PROJECT_TYPE = "Vector" - - @property - def classes_json(self): - return os.path.join( - Path(__file__).parent.parent.parent, - "data_set/sample_project_vector/classes/classes.json", - ) - - def test_create_annotation_class(self): - sa.create_annotation_class(self.PROJECT_NAME, "tt", "#FFFFFF") - classes = sa.search_annotation_classes(self.PROJECT_NAME) - self.assertEqual(len(classes), 1) - self.assertEqual(classes[0]["type"], "object") - - def test_annotation_classes_filter(self): - sa.create_annotation_class(self.PROJECT_NAME, "tt", "#FFFFFF") - sa.create_annotation_class(self.PROJECT_NAME, "tb", "#FFFFFF") - classes = sa.search_annotation_classes(self.PROJECT_NAME, "bb") - self.assertEqual(len(classes), 0) - classes = sa.search_annotation_classes(self.PROJECT_NAME, "tt") - self.assertEqual(len(classes), 1) - - def test_create_annotation_class_from_json(self): - sa.create_annotation_classes_from_classes_json( - self.PROJECT_NAME, self.classes_json - ) - self.assertEqual(len(sa.search_annotation_classes(self.PROJECT_NAME)), 4) - - sa.create_annotation_classes_from_classes_json( - self.PROJECT_NAME, self.classes_json - ) - self.assertEqual(len(sa.search_annotation_classes(self.PROJECT_NAME)), 4) diff --git a/tests/integration/annotations/test_annotation_classes.py b/tests/integration/annotations/test_annotation_classes.py deleted file mode 100644 index 271427c23..000000000 --- a/tests/integration/annotations/test_annotation_classes.py +++ /dev/null @@ -1,52 +0,0 @@ -import os -from pathlib import Path -from urllib.parse import urlparse - -from src.superannotate import SAClient -from tests.integration.base import BaseTestCase - -sa = SAClient() - - -class TestAnnotationClasses(BaseTestCase): - PROJECT_NAME_ = "TestAnnotationClasses" - PROJECT_DESCRIPTION = "desc" - PROJECT_TYPE = "Vector" - CLASSES_JON_PATH = "data_set/invalid_json/classes.json" - - @property - def classes_path(self): - return os.path.join(Path(__file__).parent.parent.parent, self.CLASSES_JON_PATH) - - def test_invalid_json(self): - try: - sa.create_annotation_classes_from_classes_json( - self.PROJECT_NAME, self.classes_path - ) - except Exception as e: - self.assertIn("Couldn't validate annotation classes", str(e)) - - def test_annotation_classes(self): - annotation_classes = sa.search_annotation_classes(self.PROJECT_NAME) - self.assertEqual(len(annotation_classes), 0) - sa.create_annotation_class(self.PROJECT_NAME, "fff", "#FFFFFF") - annotation_classes = sa.search_annotation_classes(self.PROJECT_NAME) - self.assertEqual(len(annotation_classes), 1) - - annotation_class = sa.search_annotation_classes(self.PROJECT_NAME, "ff")[0] - sa.delete_annotation_class(self.PROJECT_NAME, annotation_class) - annotation_classes = sa.search_annotation_classes(self.PROJECT_NAME) - self.assertEqual(len(annotation_classes), 0) - - def test_annotation_classes_from_s3(self): - annotation_classes = sa.search_annotation_classes(self.PROJECT_NAME) - self.assertEqual(len(annotation_classes), 0) - f = urlparse("s3://superannotate-python-sdk-test/sample_project_pixel") - - sa.create_annotation_classes_from_classes_json( - self.PROJECT_NAME, - f.path[1:] + "/classes/classes.json", - from_s3_bucket=f.netloc, - ) - annotation_classes = sa.search_annotation_classes(self.PROJECT_NAME) - self.assertEqual(len(annotation_classes), 5) diff --git a/tests/integration/classes/test_create_annotation_class.py b/tests/integration/classes/test_create_annotation_class.py index 7e585e369..52e344be8 100644 --- a/tests/integration/classes/test_create_annotation_class.py +++ b/tests/integration/classes/test_create_annotation_class.py @@ -4,31 +4,39 @@ import pytest from src.superannotate import AppException from src.superannotate import SAClient +from src.superannotate.lib.core.entities.classes import AnnotationClassEntity from tests import DATA_SET_PATH from tests.integration.base import BaseTestCase sa = SAClient() -class TestCreateAnnotationClass(BaseTestCase): - PROJECT_NAME = "TestCreateAnnotationClass" +class TestVectorAnnotationClasses(BaseTestCase): + PROJECT_NAME = "TestVectorAnnotationClasses" + PROJECT_DESCRIPTION = "desc" PROJECT_TYPE = "Vector" - PROJECT_DESCRIPTION = "Example " - TEST_LARGE_CLASSES_JSON = "large_classes_json.json" - EXAMPLE_IMAGE_1 = "example_image_1.jpg" - @property - def large_json_path(self): - return os.path.join(DATA_SET_PATH, self.TEST_LARGE_CLASSES_JSON) + def test_create_annotation_class_search(self): + sa.create_annotation_class(self.PROJECT_NAME, "tt", "#FFFFFF") + classes = sa.search_annotation_classes(self.PROJECT_NAME) + self.assertEqual(len(classes), 1) + self.assertEqual(classes[0]["type"], "object") + self.assertEqual(classes[0]["color"], "#FFFFFF") + sa.create_annotation_class(self.PROJECT_NAME, "tb", "#FFFFFF") + # test search + classes = sa.search_annotation_classes(self.PROJECT_NAME, "bb") + self.assertEqual(len(classes), 0) + classes = sa.search_annotation_classes(self.PROJECT_NAME, "tt") + self.assertEqual(len(classes), 1) - def test_create_annotation_class(self): + def test_create_tag_annotation_class(self): sa.create_annotation_class( self.PROJECT_NAME, "test_add", "#FF0000", class_type="tag" ) classes = sa.search_annotation_classes(self.PROJECT_NAME) self.assertEqual(classes[0]["type"], "tag") - def test_create_annotation_class_with_attr(self): + def test_create_annotation_class_with_attr_and_default_value(self): _class = sa.create_annotation_class( self.PROJECT_NAME, "test_add", @@ -37,26 +45,17 @@ def test_create_annotation_class_with_attr(self): { "name": "test", "attributes": [{"name": "Car"}, {"name": "Track"}, {"name": "Bus"}], + "default_value": "Bus", } ], ) assert "is_multiselect" not in _class["attribute_groups"][0] classes = sa.search_annotation_classes(self.PROJECT_NAME) assert "is_multiselect" not in classes[0]["attribute_groups"][0] + assert classes[0]["attribute_groups"][0]["default_value"] == "Bus" - def test_create_annotations_classes_from_class_json(self): - classes = sa.create_annotation_classes_from_classes_json( - self.PROJECT_NAME, self.large_json_path - ) - self.assertEqual(len(classes), 1500) - assert "is_multiselect" not in str(classes) - - def test_hex_color_adding(self): - sa.create_annotation_class(self.PROJECT_NAME, "test_add", color="#0000FF") - classes = sa.search_annotation_classes(self.PROJECT_NAME, "test_add") - assert classes[0]["color"] == "#0000FF" - - def test_create_annotation_class_with_default_attribute(self): + @pytest.mark.flaky(reruns=2) + def test_multi_select_to_checklist(self): sa.create_annotation_class( self.PROJECT_NAME, "test_add", @@ -65,43 +64,48 @@ def test_create_annotation_class_with_default_attribute(self): attribute_groups=[ { "name": "test", + "is_multiselect": 1, "attributes": [{"name": "Car"}, {"name": "Track"}, {"name": "Bus"}], - "default_value": "Bus", } ], ) classes = sa.search_annotation_classes(self.PROJECT_NAME) - assert classes[0]["attribute_groups"][0]["default_value"] == "Bus" + assert classes[0]["attribute_groups"][0]["group_type"] == "checklist" + assert classes[0]["attribute_groups"][0]["default_value"] == [] - def test_create_annotation_classes_with_default_attribute(self): - sa.create_annotation_classes_from_classes_json( - self.PROJECT_NAME, - classes_json=[ - { - "name": "Personal vehicle", - "color": "#ecb65f", - "count": 25, - "createdAt": "2020-10-12T11:35:20.000Z", - "updatedAt": "2020-10-12T11:48:19.000Z", - "attribute_groups": [ - { - "name": "test", - "attributes": [ - {"name": "Car"}, - {"name": "Track"}, - {"name": "Bus"}, - ], - "default_value": "Bus", - } - ], - } - ], + @pytest.mark.skip(reason="Need to adjust") + def test_create_annotation_class_video_error(self): + msg = "" + try: + sa.create_annotation_class( + self.PROJECT_NAME, "test_add", "#FF0000", class_type="tag" + ) + except Exception as e: + msg = str(e) + self.assertEqual( + msg, + "Predefined tagging functionality is not supported for projects of type Video.", ) - classes = sa.search_annotation_classes(self.PROJECT_NAME) - assert classes[0]["attribute_groups"][0]["default_value"] == "Bus" + + def test_create_radio_annotation_class_attr_required(self): + msg = "" + try: + sa.create_annotation_class( + self.PROJECT_NAME, + "test_add", + "#FF0000", + attribute_groups=[ + { + "group_type": "radio", + "name": "name", + } + ], + ) + except Exception as e: + msg = str(e) + self.assertEqual(msg, '"classes[0].attribute_groups[0].attributes" is required') def test_create_annotation_class_backend_errors(self): - from lib.core.entities.classes import AnnotationClassEntity response = sa.controller.annotation_classes.create( sa.controller.projects.get_by_name(self.PROJECT_NAME).data, @@ -156,47 +160,141 @@ def test_create_annotation_classes_with_empty_default_attribute(self): assert classes[0]["attribute_groups"][0]["default_value"] is None assert "is_multiselect" not in classes[0]["attribute_groups"][0] + def test_class_creation_type(self): + with tempfile.TemporaryDirectory() as tmpdir_name: + temp_path = f"{tmpdir_name}/new_classes.json" + with open(temp_path, "w") as new_classes: + new_classes.write( + """ + [ + { + "id":56820, + "project_id":7617, + "name":"Personal vehicle", + "color":"#547497", + "count":18, + "createdAt":"2020-09-29T10:39:39.000Z", + "updatedAt":"2020-09-29T10:48:18.000Z", + "type": "tag", + "attribute_groups":[ + { + "id":21448, + "class_id":56820, + "name":"Large", + "is_multiselect":0, + "createdAt":"2020-09-29T10:39:39.000Z", + "updatedAt":"2020-09-29T10:39:39.000Z", + "attributes":[ + { + "id":57096, + "group_id":21448, + "project_id":7617, + "name":"no", + "count":0, + "createdAt":"2020-09-29T10:39:39.000Z", + "updatedAt":"2020-09-29T10:39:39.000Z" + }, + { + "id":57097, + "group_id":21448, + "project_id":7617, + "name":"yes", + "count":1, + "createdAt":"2020-09-29T10:39:39.000Z", + "updatedAt":"2020-09-29T10:48:18.000Z" + } + ] + } + ] + }, + { + "id":56821, + "project_id":7617, + "name":"Large vehicle", + "color":"#2ba36d", + "count":1, + "createdAt":"2020-09-29T10:39:39.000Z", + "updatedAt":"2020-09-29T10:48:18.000Z", + "attribute_groups":[ + { + "id":21449, + "class_id":56821, + "name":"small", + "is_multiselect":0, + "createdAt":"2020-09-29T10:39:39.000Z", + "updatedAt":"2020-09-29T10:39:39.000Z", + "attributes":[ + { + "id":57098, + "group_id":21449, + "project_id":7617, + "name":"yes", + "count":0, + "createdAt":"2020-09-29T10:39:39.000Z", + "updatedAt":"2020-09-29T10:39:39.000Z" + }, + { + "id":57099, + "group_id":21449, + "project_id":7617, + "name":"no", + "count":1, + "createdAt":"2020-09-29T10:39:39.000Z", + "updatedAt":"2020-09-29T10:48:18.000Z" + } + ] + } + ] + }, + { + "id":56822, + "project_id":7617, + "name":"Pedestrian", + "color":"#d4da03", + "count":3, + "createdAt":"2020-09-29T10:39:39.000Z", + "updatedAt":"2020-09-29T10:48:18.000Z", + "attribute_groups":[ -class TestCreateAnnotationClassNonVectorWithError(BaseTestCase): - PROJECT_NAME = "TestCreateAnnotationClassNonVectorWithError" - PROJECT_TYPE = "Video" - PROJECT_DESCRIPTION = "Example Project test pixel basic images" + ] + }, + { + "id":56823, + "project_id":7617, + "name":"Two wheeled vehicle", + "color":"#f11aec", + "count":1, + "createdAt":"2020-09-29T10:39:39.000Z", + "updatedAt":"2020-09-29T10:48:18.000Z", + "attribute_groups":[ - @pytest.mark.skip(reason="Need to adjust") - def test_create_annotation_class(self): - msg = "" - try: - sa.create_annotation_class( - self.PROJECT_NAME, "test_add", "#FF0000", class_type="tag" - ) - except Exception as e: - msg = str(e) - self.assertEqual( - msg, - "Predefined tagging functionality is not supported for projects of type Video.", - ) + ] + }, + { + "id":56824, + "project_id":7617, + "name":"Traffic sign", + "color":"#d8a7fd", + "count":9, + "createdAt":"2020-09-29T10:39:39.000Z", + "updatedAt":"2020-09-29T10:48:18.000Z", + "attribute_groups":[ - def test_create_radio_annotation_class_attr_required(self): - msg = "" - try: - sa.create_annotation_class( - self.PROJECT_NAME, - "test_add", - "#FF0000", - attribute_groups=[ - { - "group_type": "radio", - "name": "name", - } - ], + ] + } + ] + + """ + ) + + created = sa.create_annotation_classes_from_classes_json( + self.PROJECT_NAME, temp_path ) - except Exception as e: - msg = str(e) - self.assertEqual(msg, '"classes[0].attribute_groups[0].attributes" is required') + self.assertEqual({i["type"] for i in created}, {"tag", "object"}) -class TestCreateAnnotationClassesNonVectorWithError(BaseTestCase): - PROJECT_NAME = "TestCreateAnnotationClassesNonVectorWithError" +class TestVideoCreateAnnotationClasses(BaseTestCase): + PROJECT_NAME = "TestVideoCreateAnnotationClasses" PROJECT_TYPE = "Video" PROJECT_DESCRIPTION = "Example Project test pixel basic images" @@ -266,52 +364,12 @@ def test_create_annotation_class_via_ocr_group_type(self): self.PROJECT_NAME, "test_add", "#FF0000", - attribute_groups, + attribute_groups, # noqa class_type="tag", ) - def test_create_annotation_class_via_json_and_ocr_group_type(self): - with tempfile.TemporaryDirectory() as tmpdir_name: - temp_path = f"{tmpdir_name}/new_classes.json" - with open(temp_path, "w") as new_classes: - new_classes.write( - """ - [ - { - "id":56820, - "project_id":7617, - "name":"Personal vehicle", - "color":"#547497", - "count":18, - "createdAt":"2020-09-29T10:39:39.000Z", - "updatedAt":"2020-09-29T10:48:18.000Z", - "type": "tag", - "attribute_groups":[ - { - "id":21448, - "class_id":56820, - "name":"Large", - "group_type": "ocr", - "is_multiselect":0, - "createdAt":"2020-09-29T10:39:39.000Z", - "updatedAt":"2020-09-29T10:39:39.000Z", - "attributes":[] - } - ] - } - ] - """ - ) - with self.assertRaisesRegexp( - AppException, - f"OCR attribute group is not supported for project type {self.PROJECT_TYPE}.", - ): - sa.create_annotation_classes_from_classes_json( - self.PROJECT_NAME, temp_path - ) - -class TestCreateAnnotationClassPixel(BaseTestCase): +class TestPixelCreateAnnotationClass(BaseTestCase): PROJECT_NAME = "TestCreateAnnotationClassPixel" PROJECT_TYPE = "Pixel" PROJECT_DESCRIPTION = "Example " @@ -342,32 +400,3 @@ def test_create_annotation_class_with_default_attribute(self): } ], ) - - def test_create_annotation_classes_with_default_attribute(self): - with self.assertRaisesRegexp( - AppException, - 'The "default_value" key is not supported for project type Pixel.', - ): - sa.create_annotation_classes_from_classes_json( - self.PROJECT_NAME, - classes_json=[ - { - "name": "Personal vehicle", - "color": "#ecb65f", - "count": 25, - "createdAt": "2020-10-12T11:35:20.000Z", - "updatedAt": "2020-10-12T11:48:19.000Z", - "attribute_groups": [ - { - "name": "test", - "attributes": [ - {"name": "Car"}, - {"name": "Track"}, - {"name": "Bus"}, - ], - "default_value": "Bus", - } - ], - } - ], - ) diff --git a/tests/integration/classes/test_create_annotation_classes_from_classes_json.py b/tests/integration/classes/test_create_annotation_classes_from_classes_json.py new file mode 100644 index 000000000..053c18503 --- /dev/null +++ b/tests/integration/classes/test_create_annotation_classes_from_classes_json.py @@ -0,0 +1,208 @@ +import os +import tempfile +from pathlib import Path +from urllib.parse import urlparse + +import pytest +from src.superannotate import AppException +from src.superannotate import SAClient +from tests import DATA_SET_PATH +from tests.integration.base import BaseTestCase + +sa = SAClient() + + +class TestVectorCreateAnnotationClass(BaseTestCase): + PROJECT_NAME = "TestCreateAnnotationClass" + PROJECT_TYPE = "Vector" + PROJECT_DESCRIPTION = "Example " + TEST_LARGE_CLASSES_JSON = "large_classes_json.json" + EXAMPLE_IMAGE_1 = "example_image_1.jpg" + INVALID_CLASSES_JON_PATH = "data_set/invalid_json/classes.json" + + @property + def large_json_path(self): + return os.path.join(DATA_SET_PATH, self.TEST_LARGE_CLASSES_JSON) + + @property + def invalid_classes_path(self): + return os.path.join( + Path(__file__).parent.parent.parent, self.INVALID_CLASSES_JON_PATH + ) + + @property + def classes_json(self): + return os.path.join( + Path(__file__).parent.parent.parent, + "data_set/sample_project_vector/classes/classes.json", + ) + + def test_create_annotation_class_from_json(self): + sa.create_annotation_classes_from_classes_json( + self.PROJECT_NAME, self.classes_json + ) + self.assertEqual(len(sa.search_annotation_classes(self.PROJECT_NAME)), 4) + + sa.create_annotation_classes_from_classes_json( + self.PROJECT_NAME, self.classes_json + ) + self.assertEqual(len(sa.search_annotation_classes(self.PROJECT_NAME)), 4) + + def test_invalid_json(self): + try: + sa.create_annotation_classes_from_classes_json( + self.PROJECT_NAME, self.invalid_classes_path + ) + except Exception as e: + self.assertIn("Couldn't validate annotation classes", str(e)) + + def test_create_annotations_classes_is_multiselect(self): + classes = sa.create_annotation_classes_from_classes_json( + self.PROJECT_NAME, self.large_json_path + ) + self.assertEqual(len(classes), 1500) + assert "is_multiselect" not in str(classes) + + def test_create_annotation_classes_from_s3(self): + annotation_classes = sa.search_annotation_classes(self.PROJECT_NAME) + self.assertEqual(len(annotation_classes), 0) + f = urlparse("s3://superannotate-python-sdk-test/sample_project_pixel") + + sa.create_annotation_classes_from_classes_json( + self.PROJECT_NAME, + f.path[1:] + "/classes/classes.json", + from_s3_bucket=f.netloc, + ) + annotation_classes = sa.search_annotation_classes(self.PROJECT_NAME) + self.assertEqual(len(annotation_classes), 5) + + +class TestVideoCreateAnnotationClasses(BaseTestCase): + PROJECT_NAME = "TestVideoCreateAnnotationClasses" + PROJECT_TYPE = "Video" + PROJECT_DESCRIPTION = "Example Project test pixel basic images" + + @pytest.mark.skip(reason="Need to adjust") + def test_create_annotation_class(self): + with tempfile.TemporaryDirectory() as tmpdir_name: + temp_path = f"{tmpdir_name}/new_classes.json" + with open(temp_path, "w") as new_classes: + new_classes.write( + """ + [ + { + "id":56820, + "project_id":7617, + "name":"Personal vehicle", + "color":"#547497", + "count":18, + "createdAt":"2020-09-29T10:39:39.000Z", + "updatedAt":"2020-09-29T10:48:18.000Z", + "type": "tag", + "attribute_groups":[ + { + "id":21448, + "class_id":56820, + "name":"Large", + "is_multiselect":0, + "createdAt":"2020-09-29T10:39:39.000Z", + "updatedAt":"2020-09-29T10:39:39.000Z", + "attributes":[] + } + ] + } + ] + + """ + ) + msg = "" + try: + sa.create_annotation_classes_from_classes_json( + self.PROJECT_NAME, temp_path + ) + except Exception as e: + msg = str(e) + self.assertEqual( + msg, + "Predefined tagging functionality is not supported for projects of type Video.", + ) + + def test_create_annotation_class_via_json_and_ocr_group_type(self): + with tempfile.TemporaryDirectory() as tmpdir_name: + temp_path = f"{tmpdir_name}/new_classes.json" + with open(temp_path, "w") as new_classes: + new_classes.write( + """ + [ + { + "id":56820, + "project_id":7617, + "name":"Personal vehicle", + "color":"#547497", + "count":18, + "createdAt":"2020-09-29T10:39:39.000Z", + "updatedAt":"2020-09-29T10:48:18.000Z", + "type": "tag", + "attribute_groups":[ + { + "id":21448, + "class_id":56820, + "name":"Large", + "group_type": "ocr", + "is_multiselect":0, + "createdAt":"2020-09-29T10:39:39.000Z", + "updatedAt":"2020-09-29T10:39:39.000Z", + "attributes":[] + } + ] + } + ] + """ + ) + with self.assertRaisesRegexp( + AppException, + f"OCR attribute group is not supported for project type {self.PROJECT_TYPE}.", + ): + sa.create_annotation_classes_from_classes_json( + self.PROJECT_NAME, temp_path + ) + + +class TestPixelCreateAnnotationClass(BaseTestCase): + PROJECT_NAME = "TestCreateAnnotationClassPixel" + PROJECT_TYPE = "Pixel" + PROJECT_DESCRIPTION = "Example " + TEST_LARGE_CLASSES_JSON = "large_classes_json.json" + + @property + def large_json_path(self): + return os.path.join(DATA_SET_PATH, self.TEST_LARGE_CLASSES_JSON) + + def test_create_annotation_classes_with_default_attribute(self): + with self.assertRaisesRegexp( + AppException, + 'The "default_value" key is not supported for project type Pixel.', + ): + sa.create_annotation_classes_from_classes_json( + self.PROJECT_NAME, + classes_json=[ + { + "name": "Personal vehicle", + "color": "#ecb65f", + "count": 25, + "createdAt": "2020-10-12T11:35:20.000Z", + "updatedAt": "2020-10-12T11:48:19.000Z", + "attribute_groups": [ + { + "name": "test", + "attributes": [ + {"name": "Car"}, + {"name": "Track"}, + {"name": "Bus"}, + ], + "default_value": "Bus", + } + ], + } + ], + ) diff --git a/tests/integration/classes/test_create_bed_handling.py b/tests/integration/classes/test_create_bed_handling.py deleted file mode 100644 index 926eb872b..000000000 --- a/tests/integration/classes/test_create_bed_handling.py +++ /dev/null @@ -1,32 +0,0 @@ -import pytest -from src.superannotate import SAClient -from tests.integration.base import BaseTestCase - -sa = SAClient() - - -class TestCreateAnnotationClass(BaseTestCase): - PROJECT_NAME = "TestCreateAnnotationClassBED" - PROJECT_TYPE = "Vector" - PROJECT_DESCRIPTION = "Example " - TEST_LARGE_CLASSES_JSON = "large_classes_json.json" - EXAMPLE_IMAGE_1 = "example_image_1.jpg" - - @pytest.mark.flaky(reruns=2) - def test_multi_select_to_checklist(self): - sa.create_annotation_class( - self.PROJECT_NAME, - "test_add", - "#FF0000", - class_type="tag", - attribute_groups=[ - { - "name": "test", - "is_multiselect": 1, - "attributes": [{"name": "Car"}, {"name": "Track"}, {"name": "Bus"}], - } - ], - ) - classes = sa.search_annotation_classes(self.PROJECT_NAME) - assert classes[0]["attribute_groups"][0]["group_type"] == "checklist" - assert classes[0]["attribute_groups"][0]["default_value"] == [] diff --git a/tests/integration/classes/test_tag_annotation_classes.py b/tests/integration/classes/test_tag_annotation_classes.py deleted file mode 100644 index 967383f48..000000000 --- a/tests/integration/classes/test_tag_annotation_classes.py +++ /dev/null @@ -1,146 +0,0 @@ -import tempfile - -from src.superannotate import SAClient -from tests.integration.base import BaseTestCase - -sa = SAClient() - - -class TestTagClasses(BaseTestCase): - PROJECT_NAME = "sample_project_pixel" - PROJECT_TYPE = "Vector" - PROJECT_DESCRIPTION = "Example Project test pixel basic images" - TEST_FOLDER_PTH = "data_set/sample_project_pixel" - EXAMPLE_IMAGE_1 = "example_image_1.jpg" - - def test_class_creation_type(self): - with tempfile.TemporaryDirectory() as tmpdir_name: - temp_path = f"{tmpdir_name}/new_classes.json" - with open(temp_path, "w") as new_classes: - new_classes.write( - """ - [ - { - "id":56820, - "project_id":7617, - "name":"Personal vehicle", - "color":"#547497", - "count":18, - "createdAt":"2020-09-29T10:39:39.000Z", - "updatedAt":"2020-09-29T10:48:18.000Z", - "type": "tag", - "attribute_groups":[ - { - "id":21448, - "class_id":56820, - "name":"Large", - "is_multiselect":0, - "createdAt":"2020-09-29T10:39:39.000Z", - "updatedAt":"2020-09-29T10:39:39.000Z", - "attributes":[ - { - "id":57096, - "group_id":21448, - "project_id":7617, - "name":"no", - "count":0, - "createdAt":"2020-09-29T10:39:39.000Z", - "updatedAt":"2020-09-29T10:39:39.000Z" - }, - { - "id":57097, - "group_id":21448, - "project_id":7617, - "name":"yes", - "count":1, - "createdAt":"2020-09-29T10:39:39.000Z", - "updatedAt":"2020-09-29T10:48:18.000Z" - } - ] - } - ] - }, - { - "id":56821, - "project_id":7617, - "name":"Large vehicle", - "color":"#2ba36d", - "count":1, - "createdAt":"2020-09-29T10:39:39.000Z", - "updatedAt":"2020-09-29T10:48:18.000Z", - "attribute_groups":[ - { - "id":21449, - "class_id":56821, - "name":"small", - "is_multiselect":0, - "createdAt":"2020-09-29T10:39:39.000Z", - "updatedAt":"2020-09-29T10:39:39.000Z", - "attributes":[ - { - "id":57098, - "group_id":21449, - "project_id":7617, - "name":"yes", - "count":0, - "createdAt":"2020-09-29T10:39:39.000Z", - "updatedAt":"2020-09-29T10:39:39.000Z" - }, - { - "id":57099, - "group_id":21449, - "project_id":7617, - "name":"no", - "count":1, - "createdAt":"2020-09-29T10:39:39.000Z", - "updatedAt":"2020-09-29T10:48:18.000Z" - } - ] - } - ] - }, - { - "id":56822, - "project_id":7617, - "name":"Pedestrian", - "color":"#d4da03", - "count":3, - "createdAt":"2020-09-29T10:39:39.000Z", - "updatedAt":"2020-09-29T10:48:18.000Z", - "attribute_groups":[ - - ] - }, - { - "id":56823, - "project_id":7617, - "name":"Two wheeled vehicle", - "color":"#f11aec", - "count":1, - "createdAt":"2020-09-29T10:39:39.000Z", - "updatedAt":"2020-09-29T10:48:18.000Z", - "attribute_groups":[ - - ] - }, - { - "id":56824, - "project_id":7617, - "name":"Traffic sign", - "color":"#d8a7fd", - "count":9, - "createdAt":"2020-09-29T10:39:39.000Z", - "updatedAt":"2020-09-29T10:48:18.000Z", - "attribute_groups":[ - - ] - } - ] - - """ - ) - - created = sa.create_annotation_classes_from_classes_json( - self.PROJECT_NAME, temp_path - ) - self.assertEqual({i["type"] for i in created}, {"tag", "object"}) diff --git a/tests/integration/classes/test_classes_serialization.py b/tests/unit/test_classes_serialization.py similarity index 100% rename from tests/integration/classes/test_classes_serialization.py rename to tests/unit/test_classes_serialization.py