Skip to content

Commit a22f5e7

Browse files
committed
Fix tests
1 parent 3139b1b commit a22f5e7

File tree

2 files changed

+78
-2
lines changed

2 files changed

+78
-2
lines changed

tests/test_attach_image_urls.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,6 @@ def test_attach_image_urls():
2222
project, PATH_TO_URLS
2323
)
2424

25-
assert len(uploaded) == 8
25+
assert len(uploaded) == 7
2626
assert len(could_not_upload) == 0
27-
assert len(existing_images) == 0
27+
assert len(existing_images) == 1

tests/test_attach_text.py

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
import time
2+
from pathlib import Path
3+
4+
import pytest
5+
6+
import superannotate as sa
7+
from superannotate.exceptions import SABaseException
8+
import subprocess
9+
10+
PROJECT_NAME_TEXT = "test attach text urls"
11+
PATH_TO_URLS = Path("./tests/attach_urls.csv")
12+
PROJECT_TYPE = "Document"
13+
14+
15+
16+
def test_attach_text_cli():
17+
project_name_cli = "cli text"
18+
projects = sa.search_projects(project_name_cli, return_metadata=True)
19+
for project in projects:
20+
sa.delete_project(project)
21+
22+
time.sleep(1)
23+
project = sa.create_project(project_name_cli, "test", PROJECT_TYPE)
24+
time.sleep(1)
25+
subprocess.run(
26+
f'superannotatecli attach-document-urls --project "{project_name_cli}" --attachments {PATH_TO_URLS}',
27+
check=True,
28+
shell=True
29+
)
30+
time.sleep(1)
31+
32+
33+
34+
35+
36+
def test_attach_text_urls():
37+
projects = sa.search_projects(PROJECT_NAME_TEXT, return_metadata=True)
38+
for project in projects:
39+
sa.delete_project(project)
40+
41+
time.sleep(1)
42+
project = sa.create_project(PROJECT_NAME_TEXT, "test", PROJECT_TYPE)
43+
time.sleep(1)
44+
45+
uploaded, could_not_upload, existing_images = sa.attach_document_urls_to_project(
46+
project, PATH_TO_URLS
47+
)
48+
49+
assert len(uploaded) == 7
50+
assert len(could_not_upload) == 0
51+
assert len(existing_images) == 1
52+
53+
with pytest.raises(SABaseException) as e:
54+
sa.export_annotation("./tests/attached_export_dir_sample","some/","object_test","COCO","Video")
55+
assert str(
56+
e
57+
) == f"The function does not support projects containing {PROJECT_TYPE} attached with URLs"
58+
59+
60+
61+
with pytest.raises(SABaseException) as e:
62+
sa.import_annotation("./tests/attached_export_dir_sample", "some/", "object_test", "COCO", "Video")
63+
assert str(
64+
e
65+
) == f"The function does not support projects containing {PROJECT_TYPE} attached with URLs"
66+
67+
68+
with pytest.raises(SABaseException) as e:
69+
sa.aggregate_annotations_as_df("./tests/attached_export_dir_sample")
70+
assert str(
71+
e
72+
) == f"The function does not support projects containing {PROJECT_TYPE} attached with URLs"
73+
sa.download_image_annotations(PROJECT_NAME_TEXT,"some","some")
74+
assert str(
75+
e
76+
) == f"The function does not support projects containing {PROJECT_TYPE} attached with URLs"

0 commit comments

Comments
 (0)