|
4 | 4 | import pytest
|
5 | 5 |
|
6 | 6 | from annofabapi.util.annotation_specs import AnnotationSpecsAccessor
|
7 |
| -from annofabapi.util.attribute_restrictions import AnnotationLink, Checkbox, IntegerTextbox, Selection, StringTextbox, TrackingId |
| 7 | +from annofabapi.util.attribute_restrictions import AnnotationLink, Checkbox, IntegerTextbox, Selection, StringTextbox, TrackingId, AttributeFactory |
8 | 8 |
|
9 | 9 | accessor = AnnotationSpecsAccessor(annotation_specs=json.loads(Path("tests/data/util/attribute_restrictions/annotation_specs.json").read_text()))
|
10 | 10 |
|
@@ -161,3 +161,40 @@ def test__implyメソッドの戻りに対してimplyメソッドを実行する
|
161 | 161 | Checkbox(accessor, attribute_name="occluded").checked().imply(IntegerTextbox(accessor, attribute_name="traffic_lane").equals(2)).imply(
|
162 | 162 | StringTextbox(accessor, attribute_name="note").is_not_empty()
|
163 | 163 | )
|
| 164 | + |
| 165 | + |
| 166 | +class Test__AttributeFactory: |
| 167 | + def setup_method(self): |
| 168 | + self.annotation_specs = json.loads(Path("tests/data/util/attribute_restrictions/annotation_specs.json").read_text()) |
| 169 | + self.factory = AttributeFactory(self.annotation_specs) |
| 170 | + |
| 171 | + def test__checkbox(self): |
| 172 | + checkbox = self.factory.checkbox(attribute_name="occluded") |
| 173 | + assert isinstance(checkbox, Checkbox) |
| 174 | + assert checkbox.attribute_id == "2517f635-2269-4142-8ef4-16312b4cc9f7" |
| 175 | + |
| 176 | + def test__string_textbox(self): |
| 177 | + string_textbox = self.factory.string_textbox(attribute_name="note") |
| 178 | + assert isinstance(string_textbox, StringTextbox) |
| 179 | + assert string_textbox.attribute_id == "9b05648d-1e16-4ea2-ab79-48907f5eed00" |
| 180 | + |
| 181 | + def test__integer_textbox(self): |
| 182 | + integer_textbox = self.factory.integer_textbox(attribute_name="traffic_lane") |
| 183 | + assert isinstance(integer_textbox, IntegerTextbox) |
| 184 | + assert integer_textbox.attribute_id == "ec27de5d-122c-40e7-89bc-5500e37bae6a" |
| 185 | + |
| 186 | + def test__annotation_link(self): |
| 187 | + annotation_link = self.factory.annotation_link(attribute_name="link_car") |
| 188 | + assert isinstance(annotation_link, AnnotationLink) |
| 189 | + assert annotation_link.attribute_id == "15ba8b9d-4882-40c2-bb31-ed3f68197c2e" |
| 190 | + |
| 191 | + def test__tracking_id(self): |
| 192 | + tracking_id = self.factory.tracking_id(attribute_name="tracking") |
| 193 | + assert isinstance(tracking_id, TrackingId) |
| 194 | + assert tracking_id.attribute_id == "d349e76d-b59a-44cd-94b4-713a00b2e84d" |
| 195 | + |
| 196 | + def test__selection(self): |
| 197 | + selection = self.factory.selection(attribute_name="car_kind") |
| 198 | + assert isinstance(selection, Selection) |
| 199 | + assert selection.attribute_id == "cbb0155f-1631-48e1-8fc3-43c5f254b6f2" |
| 200 | + |
0 commit comments