Browse Source

Move test utilities to label_types app

pull/1671/head
Hironsan 2 years ago
parent
commit
f9d100d21a
5 changed files with 14 additions and 15 deletions
  1. 11
      backend/api/tests/api/utils.py
  2. 3
      backend/label_types/tests/test_views.py
  3. 8
      backend/label_types/tests/utils.py
  4. 4
      backend/labels/tests/test_views.py
  5. 3
      backend/metrics/tests.py

11
backend/api/tests/api/utils.py

@ -102,17 +102,6 @@ def make_tag(project):
return mommy.make('Tag', project=project)
def make_label(project, **kwargs):
if project.project_type.endswith('Classification'):
return mommy.make('CategoryType', project=project, **kwargs)
else:
return mommy.make('SpanType', project=project, **kwargs)
def make_auto_labeling_config(project):
return mommy.make('AutoLabelingConfig', project=project)
def prepare_project(task: str = 'Any', collaborative_annotation=False, **kwargs):
return make_project(
task=task,

3
backend/label_types/tests/test_views.py

@ -6,7 +6,8 @@ from rest_framework.reverse import reverse
from rest_framework.test import APITestCase
from projects.models import DOCUMENT_CLASSIFICATION
from api.tests.api.utils import (CRUDMixin, make_label, make_project, make_user, prepare_project)
from api.tests.api.utils import (CRUDMixin, make_project, make_user, prepare_project)
from .utils import make_label
DATA_DIR = os.path.join(os.path.dirname(__file__), 'data')

8
backend/label_types/tests/utils.py

@ -0,0 +1,8 @@
from model_mommy import mommy
def make_label(project, **kwargs):
if project.project_type.endswith('Classification'):
return mommy.make('CategoryType', project=project, **kwargs)
else:
return mommy.make('SpanType', project=project, **kwargs)

4
backend/labels/tests/test_views.py

@ -3,9 +3,9 @@ from rest_framework.reverse import reverse
from projects.models import DOCUMENT_CLASSIFICATION, SEQUENCE_LABELING, SEQ2SEQ
from labels.models import Category, Span, TextLabel
from api.tests.api.utils import (CRUDMixin, make_label,
make_user, prepare_project)
from api.tests.api.utils import (CRUDMixin, make_user, prepare_project)
from examples.tests.utils import make_doc
from label_types.tests.utils import make_label
from .utils import make_annotation

3
backend/metrics/tests.py

@ -2,8 +2,9 @@ from model_mommy import mommy
from rest_framework import status
from rest_framework.reverse import reverse
from api.tests.api.utils import CRUDMixin, prepare_project, make_label
from api.tests.api.utils import CRUDMixin, prepare_project
from examples.tests.utils import make_doc
from label_types.tests.utils import make_label
from projects.models import DOCUMENT_CLASSIFICATION

Loading…
Cancel
Save