|
|
@ -1,3 +1,5 @@ |
|
|
|
import uuid |
|
|
|
|
|
|
|
from model_mommy import mommy |
|
|
|
from rest_framework import status |
|
|
|
from rest_framework.reverse import reverse |
|
|
@ -6,8 +8,13 @@ from .utils import make_annotation |
|
|
|
from api.tests.utils import CRUDMixin |
|
|
|
from examples.tests.utils import make_doc |
|
|
|
from label_types.tests.utils import make_label |
|
|
|
from labels.models import Category, Span, TextLabel |
|
|
|
from projects.models import DOCUMENT_CLASSIFICATION, SEQ2SEQ, SEQUENCE_LABELING |
|
|
|
from labels.models import BoundingBox, Category, Span, TextLabel |
|
|
|
from projects.models import ( |
|
|
|
BOUNDING_BOX, |
|
|
|
DOCUMENT_CLASSIFICATION, |
|
|
|
SEQ2SEQ, |
|
|
|
SEQUENCE_LABELING, |
|
|
|
) |
|
|
|
from projects.tests.utils import prepare_project |
|
|
|
from users.tests.utils import make_user |
|
|
|
|
|
|
@ -63,6 +70,16 @@ class TestSpanList(TestLabelList, CRUDMixin): |
|
|
|
make_annotation(cls.task, doc=doc, user=member, start_offset=0, end_offset=1) |
|
|
|
|
|
|
|
|
|
|
|
class TestBBoxList(TestLabelList, CRUDMixin): |
|
|
|
model = BoundingBox |
|
|
|
task = BOUNDING_BOX |
|
|
|
view_name = "bbox_list" |
|
|
|
|
|
|
|
@classmethod |
|
|
|
def make_annotation(cls, doc, member): |
|
|
|
mommy.make("BoundingBox", example=doc, user=member, x=0, y=0, width=0, height=0) |
|
|
|
|
|
|
|
|
|
|
|
class TestTextList(TestLabelList, CRUDMixin): |
|
|
|
model = TextLabel |
|
|
|
task = SEQ2SEQ |
|
|
@ -179,6 +196,20 @@ class TestTextLabelCreation(TestDataLabeling, CRUDMixin): |
|
|
|
return {"text": "example"} |
|
|
|
|
|
|
|
|
|
|
|
class TestBoundingBoxCreation(TestDataLabeling, CRUDMixin): |
|
|
|
task = BOUNDING_BOX |
|
|
|
view_name = "bbox_list" |
|
|
|
|
|
|
|
def create_data(self): |
|
|
|
label = mommy.make("CategoryType", project=self.project.item) |
|
|
|
return {"x": 0, "y": 0, "width": 0, "height": 0, "label": label.id} |
|
|
|
|
|
|
|
def test_allows_project_member_to_annotate(self): |
|
|
|
for member in self.project.members: |
|
|
|
self.data["uuid"] = str(uuid.uuid4()) |
|
|
|
self.assert_create(member, status.HTTP_201_CREATED) |
|
|
|
|
|
|
|
|
|
|
|
class TestLabelDetail: |
|
|
|
task = SEQUENCE_LABELING |
|
|
|
view_name = "annotation_detail" |
|
|
@ -254,6 +285,14 @@ class TestTextDetail(TestLabelDetail, CRUDMixin): |
|
|
|
return make_annotation(task=self.task, doc=doc, user=self.project.admin) |
|
|
|
|
|
|
|
|
|
|
|
class TestBBoxDetail(TestLabelDetail, CRUDMixin): |
|
|
|
task = BOUNDING_BOX |
|
|
|
view_name = "bbox_detail" |
|
|
|
|
|
|
|
def create_annotation_data(self, doc): |
|
|
|
return mommy.make("BoundingBox", example=doc, user=self.project.admin, x=0, y=0, width=0, height=0) |
|
|
|
|
|
|
|
|
|
|
|
class TestSharedLabelDetail: |
|
|
|
task = DOCUMENT_CLASSIFICATION |
|
|
|
view_name = "annotation_detail" |
|
|
|