Skip to content

Commit e726512

Browse files
committed
added test
1 parent 273a732 commit e726512

File tree

5 files changed

+358
-1
lines changed

5 files changed

+358
-1
lines changed

src/superannotate/lib/app/interface/sdk_interface.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1574,6 +1574,8 @@ def create_annotation_class(
15741574
attribute_groups=attribute_groups,
15751575
class_type=class_type,
15761576
)
1577+
if response.errors:
1578+
raise AppException(response.errors)
15771579
return BaseSerializers(response.data).serialize()
15781580

15791581

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2846,7 +2846,7 @@ def __init__(
28462846
self._project = project
28472847

28482848
def validate_project_type(self):
2849-
if self._project.project_type in (ProjectType.PIXEL.value, ProjectType.VIDEO.value) and "tag" in any([
2849+
if self._project.project_type in (ProjectType.PIXEL.value, ProjectType.VIDEO.value) and any([
28502850
True for i in self._annotation_classes if i.type == "tag"
28512851
]):
28522852
raise AppException(
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
[
2+
{
3+
"id": 857627,
4+
"project_id": 150845,
5+
"name": "vid",
6+
"type": "tag",
7+
"color": "#0fc1c9",
8+
"count": 0,
9+
"createdAt": "2021-10-01T13:03:51.000Z",
10+
"updatedAt": "2021-10-01T13:03:51.000Z",
11+
"attribute_groups": [
12+
{
13+
"id": 337487,
14+
"class_id": 857627,
15+
"name": "attr g",
16+
"is_multiselect": 0,
17+
"createdAt": "2021-10-04T07:01:29.000Z",
18+
"updatedAt": "2021-10-04T07:01:29.000Z",
19+
"attributes": [
20+
{
21+
"id": 1174520,
22+
"group_id": 337487,
23+
"project_id": 150845,
24+
"name": "attr",
25+
"count": 0,
26+
"createdAt": "2021-10-04T07:01:31.000Z",
27+
"updatedAt": "2021-10-04T07:01:31.000Z"
28+
}
29+
]
30+
}
31+
]
32+
}
33+
]
Lines changed: 299 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,299 @@
1+
{
2+
"metadata": {
3+
"name": "video.mp4",
4+
"width": 480,
5+
"height": 270,
6+
"status": "NotStarted",
7+
"url": "https://file-examples-com.github.io/uploads/2017/04/file_example_MP4_480_1_5MG.mp4",
8+
"duration": 30526667,
9+
"projectId": 152038,
10+
"error": null,
11+
"annotatorEmail": null,
12+
"qaEmail": null
13+
},
14+
"instances": [
15+
{
16+
"meta": {
17+
"type": "bbox",
18+
"classId": 859496,
19+
"className": "vid",
20+
"pointLabels": {
21+
"3": "point label bro"
22+
},
23+
"start": 0,
24+
"end": 30526667
25+
},
26+
"parameters": [
27+
{
28+
"start": 0,
29+
"end": 30526667,
30+
"timestamps": [
31+
{
32+
"points": {
33+
"x1": 223.32,
34+
"y1": 78.45,
35+
"x2": 312.31,
36+
"y2": 176.66
37+
},
38+
"timestamp": 0,
39+
"attributes": []
40+
},
41+
{
42+
"points": {
43+
"x1": 182.08,
44+
"y1": 33.18,
45+
"x2": 283.45,
46+
"y2": 131.39
47+
},
48+
"timestamp": 17271058,
49+
"attributes": [
50+
{
51+
"id": 1175876,
52+
"groupId": 338357,
53+
"name": "attr",
54+
"groupName": "attr g"
55+
}
56+
]
57+
},
58+
{
59+
"points": {
60+
"x1": 182.32,
61+
"y1": 36.33,
62+
"x2": 284.01,
63+
"y2": 134.54
64+
},
65+
"timestamp": 18271058,
66+
"attributes": [
67+
{
68+
"id": 1175876,
69+
"groupId": 338357,
70+
"name": "attr",
71+
"groupName": "attr g"
72+
}
73+
]
74+
},
75+
{
76+
"points": {
77+
"x1": 181.49,
78+
"y1": 45.09,
79+
"x2": 283.18,
80+
"y2": 143.3
81+
},
82+
"timestamp": 19271058,
83+
"attributes": [
84+
{
85+
"id": 1175876,
86+
"groupId": 338357,
87+
"name": "attr",
88+
"groupName": "attr g"
89+
}
90+
]
91+
},
92+
{
93+
"points": {
94+
"x1": 181.9,
95+
"y1": 48.35,
96+
"x2": 283.59,
97+
"y2": 146.56
98+
},
99+
"timestamp": 19725864,
100+
"attributes": [
101+
{
102+
"id": 1175876,
103+
"groupId": 338357,
104+
"name": "attr",
105+
"groupName": "attr g"
106+
}
107+
]
108+
},
109+
{
110+
"points": {
111+
"x1": 181.49,
112+
"y1": 52.46,
113+
"x2": 283.18,
114+
"y2": 150.67
115+
},
116+
"timestamp": 20271058,
117+
"attributes": [
118+
{
119+
"id": 1175876,
120+
"groupId": 338357,
121+
"name": "attr",
122+
"groupName": "attr g"
123+
}
124+
]
125+
},
126+
{
127+
"points": {
128+
"x1": 181.49,
129+
"y1": 63.7,
130+
"x2": 283.18,
131+
"y2": 161.91
132+
},
133+
"timestamp": 21271058,
134+
"attributes": [
135+
{
136+
"id": 1175876,
137+
"groupId": 338357,
138+
"name": "attr",
139+
"groupName": "attr g"
140+
}
141+
]
142+
},
143+
{
144+
"points": {
145+
"x1": 182.07,
146+
"y1": 72.76,
147+
"x2": 283.76,
148+
"y2": 170.97
149+
},
150+
"timestamp": 22271058,
151+
"attributes": [
152+
{
153+
"id": 1175876,
154+
"groupId": 338357,
155+
"name": "attr",
156+
"groupName": "attr g"
157+
}
158+
]
159+
},
160+
{
161+
"points": {
162+
"x1": 182.07,
163+
"y1": 81.51,
164+
"x2": 283.76,
165+
"y2": 179.72
166+
},
167+
"timestamp": 23271058,
168+
"attributes": [
169+
{
170+
"id": 1175876,
171+
"groupId": 338357,
172+
"name": "attr",
173+
"groupName": "attr g"
174+
}
175+
]
176+
},
177+
{
178+
"points": {
179+
"x1": 182.42,
180+
"y1": 97.19,
181+
"x2": 284.11,
182+
"y2": 195.4
183+
},
184+
"timestamp": 24271058,
185+
"attributes": [
186+
{
187+
"id": 1175876,
188+
"groupId": 338357,
189+
"name": "attr",
190+
"groupName": "attr g"
191+
}
192+
]
193+
},
194+
{
195+
"points": {
196+
"x1": 182.42,
197+
"y1": 97.19,
198+
"x2": 284.11,
199+
"y2": 195.4
200+
},
201+
"timestamp": 30526667,
202+
"attributes": [
203+
{
204+
"id": 1175876,
205+
"groupId": 338357,
206+
"name": "attr",
207+
"groupName": "attr g"
208+
}
209+
]
210+
}
211+
]
212+
}
213+
]
214+
},
215+
{
216+
"meta": {
217+
"type": "bbox",
218+
"classId": 859496,
219+
"className": "vid",
220+
"start": 29713736,
221+
"end": 30526667
222+
},
223+
"parameters": [
224+
{
225+
"start": 29713736,
226+
"end": 30526667,
227+
"timestamps": [
228+
{
229+
"points": {
230+
"x1": 132.82,
231+
"y1": 129.12,
232+
"x2": 175.16,
233+
"y2": 188
234+
},
235+
"timestamp": 29713736,
236+
"attributes": []
237+
},
238+
{
239+
"points": {
240+
"x1": 132.82,
241+
"y1": 129.12,
242+
"x2": 175.16,
243+
"y2": 188
244+
},
245+
"timestamp": 30526667,
246+
"attributes": []
247+
}
248+
]
249+
}
250+
]
251+
},
252+
{
253+
"meta": {
254+
"type": "event",
255+
"classId": 859496,
256+
"className": "vid",
257+
"start": 5528212,
258+
"end": 7083022
259+
},
260+
"parameters": [
261+
{
262+
"start": 5528212,
263+
"end": 7083022,
264+
"timestamps": [
265+
{
266+
"timestamp": 5528212,
267+
"attributes": []
268+
},
269+
{
270+
"timestamp": 6702957,
271+
"attributes": [
272+
{
273+
"id": 1175876,
274+
"groupId": 338357,
275+
"name": "attr",
276+
"groupName": "attr g"
277+
}
278+
]
279+
},
280+
{
281+
"timestamp": 7083022,
282+
"attributes": [
283+
{
284+
"id": 1175876,
285+
"groupId": 338357,
286+
"name": "attr",
287+
"groupName": "attr g"
288+
}
289+
]
290+
}
291+
]
292+
}
293+
]
294+
}
295+
],
296+
"tags": [
297+
"some tag"
298+
]
299+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import os
2+
from pathlib import Path
3+
4+
import src.superannotate as sa
5+
from tests.integration.base import BaseTestCase
6+
7+
8+
class TestDocumentCreateAnnotationClass(BaseTestCase):
9+
PROJECT_NAME = "TestDocumentCreateAnnotationClass"
10+
TEST_FOLDER_PATH = "data_set/sample_project_vector"
11+
PROJECT_DESCRIPTION = "desc"
12+
PROJECT_TYPE = "Document"
13+
14+
def test_create_annotation_class(self):
15+
sa.create_annotation_class(
16+
self.PROJECT_NAME,
17+
"test_add",
18+
"#FF0000",
19+
[{"name": "height", "attributes": [{"name": "tall"}, {"name": "short"}]}],
20+
class_type="tag"
21+
)
22+
23+
self.assertEqual(len(sa.search_annotation_classes(self.PROJECT_NAME)), 1)

0 commit comments

Comments
 (0)