|
1 | 1 | from pathlib import Path |
2 | 2 | import json |
3 | | -import time |
4 | 3 |
|
5 | 4 | import pytest |
6 | 5 |
|
@@ -133,3 +132,39 @@ def test_add_bbox_noinit(tmpdir): |
133 | 132 | export = sa.prepare_export(project, include_fuse=True) |
134 | 133 | sa.download_export(project, export, tmpdir) |
135 | 134 | 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