Skip to content

Commit 1f87f32

Browse files
Narek MkhitaryanNarek Mkhitaryan
authored andcommitted
fix multimodal tests
1 parent b03a51f commit 1f87f32

File tree

12 files changed

+777
-477
lines changed

12 files changed

+777
-477
lines changed

tests/data_set/multimodal_form/expected_classes.json

Lines changed: 597 additions & 461 deletions
Large diffs are not rendered by default.

tests/integration/annotations/test_large_annotations.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717

1818
class TestAnnotationUploadVector(BaseTestCase):
19-
PROJECT_NAME = "Test-upload_annotations"
19+
PROJECT_NAME = "Test-upload_large_annotations"
2020
PROJECT_DESCRIPTION = "Desc"
2121
PROJECT_TYPE = "Vector"
2222
TEST_FOLDER_PATH = "data_set/sample_vector_annotations_with_tag_classes"
@@ -59,7 +59,7 @@ def test_large_annotation_upload(self):
5959
self.PROJECT_NAME, [annotation]
6060
).values()
6161
assert (
62-
"INFO:sa:Uploading 1/1 annotations to the project Test-upload_annotations."
62+
"INFO:sa:Uploading 1/1 annotations to the project Test-upload_large_annotations."
6363
== cm.output[0]
6464
)
6565
assert len(uploaded) == 1
@@ -84,15 +84,15 @@ def test_large_annotations_upload_get_download(self):
8484
self.PROJECT_NAME, annotations
8585
).values()
8686
assert (
87-
"INFO:sa:Uploading 5/5 annotations to the project Test-upload_annotations."
87+
"INFO:sa:Uploading 5/5 annotations to the project Test-upload_large_annotations."
8888
== cm.output[0]
8989
)
9090
assert len(uploaded) == 5
9191

9292
with self.assertLogs("sa", level="INFO") as cm:
9393
annotations = sa.get_annotations(self.PROJECT_NAME)
9494
assert (
95-
"INFO:sa:Getting 5 annotations from Test-upload_annotations."
95+
"INFO:sa:Getting 5 annotations from Test-upload_large_annotations."
9696
== cm.output[0]
9797
)
9898
assert len(annotations) == 5

tests/integration/annotations/test_upload_annotations.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,20 @@ class MultiModalUploadDownloadAnnotations(BaseTestCase):
146146
DATA_SET_PATH / "multimodal/annotations/jsonl/form1_with_categories.jsonl"
147147
)
148148
CLASSES_TEMPLATE_PATH = DATA_SET_PATH / "editor_templates" / "form1_classes.json"
149+
MULTIMODAL_FORM = {
150+
"components": [
151+
{
152+
"id": "r_qx07c6",
153+
"type": "audio",
154+
"permissions": [],
155+
"hasTooltip": False,
156+
"exclude": False,
157+
"label": "",
158+
"value": "",
159+
}
160+
],
161+
"readme": "",
162+
}
149163

150164
def setUp(self, *args, **kwargs):
151165
self.tearDown()
@@ -157,6 +171,7 @@ def setUp(self, *args, **kwargs):
157171
{"attribute": "CategorizeItems", "value": 1},
158172
{"attribute": "TemplateState", "value": 1},
159173
],
174+
form=self.MULTIMODAL_FORM,
160175
)
161176
project = sa.controller.get_project(self.PROJECT_NAME)
162177
# todo check

tests/integration/items/test_attach_category.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,20 @@ class TestItemAttachCategory(TestCase):
2222
Path(__file__).parent.parent.parent,
2323
"data_set/editor_templates/form1_classes.json",
2424
)
25+
MULTIMODAL_FORM = {
26+
"components": [
27+
{
28+
"id": "r_qx07c6",
29+
"type": "audio",
30+
"permissions": [],
31+
"hasTooltip": False,
32+
"exclude": False,
33+
"label": "",
34+
"value": "",
35+
}
36+
],
37+
"readme": "",
38+
}
2539

2640
@classmethod
2741
def setUpClass(cls, *args, **kwargs) -> None:
@@ -34,6 +48,7 @@ def setUpClass(cls, *args, **kwargs) -> None:
3448
{"attribute": "TemplateState", "value": 1},
3549
{"attribute": "CategorizeItems", "value": 1},
3650
],
51+
form=cls.MULTIMODAL_FORM,
3752
)
3853
team = sa.controller.team
3954
project = sa.controller.get_project(cls.PROJECT_NAME)

tests/integration/items/test_generate_items.py

Lines changed: 37 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,50 @@
1+
from unittest import TestCase
2+
13
from src.superannotate import AppException
24
from src.superannotate import SAClient
3-
from tests.integration.base import BaseTestCase
45

56
sa = SAClient()
67

78

8-
class TestGenerateItemsMM(BaseTestCase):
9+
class TestGenerateItemsMM(TestCase):
910
PROJECT_NAME = "TestGenerateItemsMM"
1011
PROJECT_DESCRIPTION = "TestGenerateItemsMM"
1112
PROJECT_TYPE = "Multimodal"
1213
FOLDER_NAME = "test_folder"
14+
MULTIMODAL_FORM = {
15+
"components": [
16+
{
17+
"id": "r_qx07c6",
18+
"type": "audio",
19+
"permissions": [],
20+
"hasTooltip": False,
21+
"exclude": False,
22+
"label": "",
23+
"value": "",
24+
}
25+
],
26+
"readme": "",
27+
}
28+
29+
def setUp(self, *args, **kwargs):
30+
sa.create_project(
31+
self.PROJECT_NAME,
32+
self.PROJECT_DESCRIPTION,
33+
self.PROJECT_TYPE,
34+
settings=[{"attribute": "TemplateState", "value": 1}],
35+
form=self.MULTIMODAL_FORM,
36+
)
37+
38+
def tearDown(self) -> None:
39+
try:
40+
projects = sa.search_projects(self.PROJECT_NAME, return_metadata=True)
41+
for project in projects:
42+
try:
43+
sa.delete_project(project)
44+
except Exception as e:
45+
print(str(e))
46+
except Exception as e:
47+
print(str(e))
1348

1449
def test_generate_items_root(self):
1550
sa.generate_items(self.PROJECT_NAME, 100, name="a")

tests/integration/items/test_item_context.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,20 @@ class TestMultimodalProjectBasic(BaseTestCase):
2020
Path(__file__).parent.parent.parent,
2121
"data_set/editor_templates/form1_classes.json",
2222
)
23+
MULTIMODAL_FORM = {
24+
"components": [
25+
{
26+
"id": "r_qx07c6",
27+
"type": "audio",
28+
"permissions": [],
29+
"hasTooltip": False,
30+
"exclude": False,
31+
"label": "",
32+
"value": "",
33+
}
34+
],
35+
"readme": "",
36+
}
2337

2438
def setUp(self, *args, **kwargs):
2539
self.tearDown()
@@ -28,6 +42,7 @@ def setUp(self, *args, **kwargs):
2842
self.PROJECT_DESCRIPTION,
2943
self.PROJECT_TYPE,
3044
settings=[{"attribute": "TemplateState", "value": 1}],
45+
form=self.MULTIMODAL_FORM,
3146
)
3247
team = sa.controller.team
3348
project = sa.controller.get_project(self.PROJECT_NAME)

tests/integration/items/test_list_items.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,20 @@ class TestListItemsMultimodal(BaseTestCase):
7878
]
7979
CLASSES_TEMPLATE_PATH = DATA_SET_PATH / "editor_templates/form1_classes.json"
8080
EDITOR_TEMPLATE_PATH = DATA_SET_PATH / "editor_templates/form1.json"
81+
MULTIMODAL_FORM = {
82+
"components": [
83+
{
84+
"id": "r_qx07c6",
85+
"type": "audio",
86+
"permissions": [],
87+
"hasTooltip": False,
88+
"exclude": False,
89+
"label": "",
90+
"value": "",
91+
}
92+
],
93+
"readme": "",
94+
}
8195

8296
def setUp(self, *args, **kwargs):
8397
self.tearDown()
@@ -89,6 +103,7 @@ def setUp(self, *args, **kwargs):
89103
{"attribute": "CategorizeItems", "value": 1},
90104
{"attribute": "TemplateState", "value": 1},
91105
],
106+
form=self.MULTIMODAL_FORM,
92107
)
93108
project = sa.controller.get_project(self.PROJECT_NAME)
94109
with open(self.EDITOR_TEMPLATE_PATH) as f:

tests/integration/projects/test_basic_project.py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,35 @@ class TestMultimodalProjectBasic(BaseTestCase):
1818
ANNOTATION_PATH = (
1919
"data_set/sample_project_vector/example_image_1.jpg___objects.json"
2020
)
21+
MULTIMODAL_FORM = {
22+
"components": [
23+
{
24+
"id": "r_qx07c6",
25+
"type": "audio",
26+
"permissions": [],
27+
"hasTooltip": False,
28+
"exclude": False,
29+
"label": "",
30+
"value": "",
31+
}
32+
],
33+
"readme": "",
34+
}
35+
36+
def setUp(self, *args, **kwargs):
37+
self.tearDown()
38+
self._project = sa.create_project(
39+
self.PROJECT_NAME,
40+
self.PROJECT_DESCRIPTION,
41+
self.PROJECT_TYPE,
42+
form=self.MULTIMODAL_FORM,
43+
)
44+
45+
def tearDown(self) -> None:
46+
try:
47+
sa.delete_project(self.PROJECT_NAME)
48+
except Exception as e:
49+
print(str(e))
2150

2251
@property
2352
def annotation_path(self):

tests/integration/work_management/test_contributors_categories.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,20 @@ class TestContributorsCategories(TestCase):
2222
Path(__file__).parent.parent.parent,
2323
"data_set/editor_templates/form1_classes.json",
2424
)
25+
MULTIMODAL_FORM = {
26+
"components": [
27+
{
28+
"id": "r_qx07c6",
29+
"type": "audio",
30+
"permissions": [],
31+
"hasTooltip": False,
32+
"exclude": False,
33+
"label": "",
34+
"value": "",
35+
}
36+
],
37+
"readme": "",
38+
}
2539

2640
@classmethod
2741
def setUpClass(cls, *args, **kwargs) -> None:
@@ -34,6 +48,7 @@ def setUpClass(cls, *args, **kwargs) -> None:
3448
{"attribute": "TemplateState", "value": 1},
3549
{"attribute": "CategorizeItems", "value": 2},
3650
],
51+
form=cls.MULTIMODAL_FORM,
3752
)
3853
team = sa.controller.team
3954
project = sa.controller.get_project(cls.PROJECT_NAME)

tests/integration/work_management/test_project_categories.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,20 @@ class TestProjectCategories(TestCase):
2222
Path(__file__).parent.parent.parent,
2323
"data_set/editor_templates/form1_classes.json",
2424
)
25+
MULTIMODAL_FORM = {
26+
"components": [
27+
{
28+
"id": "r_qx07c6",
29+
"type": "audio",
30+
"permissions": [],
31+
"hasTooltip": False,
32+
"exclude": False,
33+
"label": "",
34+
"value": "",
35+
}
36+
],
37+
"readme": "",
38+
}
2539

2640
@classmethod
2741
def setUpClass(cls, *args, **kwargs) -> None:
@@ -34,6 +48,7 @@ def setUpClass(cls, *args, **kwargs) -> None:
3448
{"attribute": "TemplateState", "value": 1},
3549
{"attribute": "CategorizeItems", "value": 1},
3650
],
51+
form=cls.MULTIMODAL_FORM,
3752
)
3853
team = sa.controller.team
3954
project = sa.controller.get_project(cls.PROJECT_NAME)

0 commit comments

Comments
 (0)