From f9d100d21a8365022df31d56804e49aab9f55308 Mon Sep 17 00:00:00 2001 From: Hironsan Date: Fri, 4 Feb 2022 15:42:14 +0900 Subject: [PATCH] Move test utilities to label_types app --- backend/api/tests/api/utils.py | 11 ----------- backend/label_types/tests/test_views.py | 3 ++- backend/label_types/tests/utils.py | 8 ++++++++ backend/labels/tests/test_views.py | 4 ++-- backend/metrics/tests.py | 3 ++- 5 files changed, 14 insertions(+), 15 deletions(-) create mode 100644 backend/label_types/tests/utils.py diff --git a/backend/api/tests/api/utils.py b/backend/api/tests/api/utils.py index 60a32234..9dc65dcf 100644 --- a/backend/api/tests/api/utils.py +++ b/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, diff --git a/backend/label_types/tests/test_views.py b/backend/label_types/tests/test_views.py index 289f519f..bb05f737 100644 --- a/backend/label_types/tests/test_views.py +++ b/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') diff --git a/backend/label_types/tests/utils.py b/backend/label_types/tests/utils.py new file mode 100644 index 00000000..4eb41d39 --- /dev/null +++ b/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) diff --git a/backend/labels/tests/test_views.py b/backend/labels/tests/test_views.py index 7d912b93..28d0b9ba 100644 --- a/backend/labels/tests/test_views.py +++ b/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 diff --git a/backend/metrics/tests.py b/backend/metrics/tests.py index da1d75da..2757b700 100644 --- a/backend/metrics/tests.py +++ b/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