@@ -172,3 +172,121 @@ def test_validate_annotation_with_wrong_bbox(self):
172172 "template,cuboid,polygon,point,polyline,ellipse,rbbox" ,
173173 out .getvalue ().strip ().replace (" " , "" )
174174 )
175+
176+ def test_validate_document_annotation (self ):
177+ with tempfile .TemporaryDirectory () as tmpdir_name :
178+ with open (f"{ tmpdir_name } /doc.json" , "w" ) as doc_json :
179+ doc_json .write (
180+ '''
181+ {
182+ "metadata": {
183+ "name": "text_file_example_1",
184+ "status": "NotStarted",
185+ "url": "https://sa-public-files.s3.us-west-2.amazonaws.com/Text+project/text_file_example_1.txt",
186+ "projectId": 167826,
187+ "annotatorEmail": null,
188+ "qaEmail": null,
189+ "lastAction": {
190+ "email": "some.email@gmail.com"
191+ "timestamp": 1636620976450
192+ }
193+ },
194+ "instances": [],
195+ "tags": [],
196+ "freeText": ""
197+ }
198+ '''
199+ )
200+ self .assertTrue (sa .validate_annotations ("Document" , os .path .join (self .vector_folder_path , f"{ tmpdir_name } /doc.json" )))
201+
202+
203+ def test_validate_pixel_annotation (self ):
204+ with tempfile .TemporaryDirectory () as tmpdir_name :
205+ with open (f"{ tmpdir_name } /pixel.json" , "w" ) as pix_json :
206+ pix_json .write (
207+ '''
208+ {
209+ "metadata": {
210+ "lastAction": {
211+ "email": "some.email@gmail.com"
212+ "timestamp": 1636627539398
213+ },
214+ "width": 1024,
215+ "height": 683,
216+ "name": "example_image_1.jpg",
217+ "projectId": 164324,
218+ "isPredicted": false,
219+ "isSegmented": false,
220+ "status": "NotStarted",
221+ "pinned": false,
222+ "annotatorEmail": null,
223+ "qaEmail": null
224+ },
225+ "comments": [],
226+ "tags": [],
227+ "instances": []
228+ }
229+ '''
230+ )
231+ self .assertTrue (sa .validate_annotations ("Pixel" , os .path .join (self .vector_folder_path , f"{ tmpdir_name } /pixel.json" )))
232+
233+ def test_validate_video_export_annotation (self ):
234+ with tempfile .TemporaryDirectory () as tmpdir_name :
235+ with open (f"{ tmpdir_name } /video_export.json" , "w" ) as video_export :
236+ video_export .write (
237+ '''
238+ {
239+ "metadata": {
240+ "name": "video.mp4",
241+ "width": 848,
242+ "height": 476,
243+ "status": "NotStarted",
244+ "url": "https://file-examples-com.github.io/uploads/2017/04/file_example_MP4_480_1_5MG.mp4",
245+ "duration": 2817000,
246+ "projectId": 164334,
247+ "error": null,
248+ "annotatorEmail": null,
249+ "qaEmail": null,
250+ "lastAction": {
251+ "timestamp": 1636384061135,
252+ "email": "some.email@gmail.com"
253+ }
254+ },
255+ "instances": [],
256+ "tags": []
257+ }
258+ '''
259+ )
260+ self .assertTrue (sa .validate_annotations ("Video" , os .path .join (self .vector_folder_path ,
261+ f"{ tmpdir_name } /video_export.json" )))
262+
263+
264+ def test_validate_vector_empty_annotation (self ):
265+ with tempfile .TemporaryDirectory () as tmpdir_name :
266+ with open (f"{ tmpdir_name } /vector_empty.json" , "w" ) as vector_empty :
267+ vector_empty .write (
268+ '''
269+ {
270+ "metadata": {
271+ "lastAction": {
272+ "email": "shab.prog@gmail.com",
273+ "timestamp": 1636627956948
274+ },
275+ "width": 1024,
276+ "height": 683,
277+ "name": "example_image_1.jpg",
278+ "projectId": 162462,
279+ "isPredicted": false,
280+ "status": "NotStarted",
281+ "pinned": false,
282+ "annotatorEmail": null,
283+ "qaEmail": null
284+ },
285+ "comments": [],
286+ "tags": [],
287+ "instances": []
288+ }
289+ '''
290+ )
291+ self .assertTrue (sa .validate_annotations ("Vector" , os .path .join (self .vector_folder_path ,
292+ f"{ tmpdir_name } /vector_empty.json" )))
0 commit comments