Skip to content

Commit d2fa601

Browse files
committed
Add a annotation adding test
1 parent 2cb160a commit d2fa601

File tree

2 files changed

+37
-2
lines changed

2 files changed

+37
-2
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ clean:
2424
coverage: test_coverage
2525

2626
test_coverage:
27-
$(PYTESTS) --cov=superannotate -n 8
27+
-$(PYTESTS) --cov=superannotate -n 8
2828
$(COVERAGE) html
2929
@echo "\033[95m\n\nCoverage successful! View the output at file://htmlcov/index.html.\n\033[0m"
3030

tests/test_annotation_adding.py

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
from pathlib import Path
22
import json
3-
import time
43

54
import pytest
65

@@ -133,3 +132,39 @@ def test_add_bbox_noinit(tmpdir):
133132
export = sa.prepare_export(project, include_fuse=True)
134133
sa.download_export(project, export, tmpdir)
135134
assert len(list(Path(tmpdir).rglob("*.*"))) == 4
135+
136+
137+
def test_add_bbox_json(tmpdir):
138+
tmpdir = Path(tmpdir)
139+
140+
dest = tmpdir / "test.json"
141+
src = Path(
142+
"./tests/sample_project_vector/example_image_1.jpg___objects.json"
143+
)
144+
dest.write_text(src.read_text())
145+
annotations = json.load(open(dest))
146+
sa.add_annotation_bbox_to_json(dest, [10, 10, 500, 100], "test_add")
147+
sa.add_annotation_polyline_to_json(
148+
dest, [110, 110, 510, 510, 600, 510], "test_add"
149+
)
150+
sa.add_annotation_polygon_to_json(
151+
dest, [100, 100, 500, 500, 200, 300], "test_add",
152+
[{
153+
"name": "tall",
154+
"groupName": "height"
155+
}]
156+
)
157+
sa.add_annotation_point_to_json(dest, [250, 250], "test_add")
158+
sa.add_annotation_ellipse_to_json(dest, [405, 405, 20, 70, 15], "test_add")
159+
sa.add_annotation_template_to_json(
160+
dest, [600, 30, 630, 30, 615, 60], [1, 3, 2, 3], "test_add"
161+
)
162+
sa.add_annotation_cuboid_to_json(
163+
dest, [800, 500, 900, 600, 850, 450, 950, 700], "test_add"
164+
)
165+
sa.add_annotation_comment_to_json(
166+
dest, "hey", [100, 100], "hovnatan@superannotate.com", True
167+
)
168+
annotations_new = json.load(open(dest))
169+
170+
assert len(annotations_new) == len(annotations) + 8

0 commit comments

Comments
 (0)