diff --git a/backend/api/tests/api/utils.py b/backend/api/tests/api/utils.py index 9dc65dcf..48d9cf44 100644 --- a/backend/api/tests/api/utils.py +++ b/backend/api/tests/api/utils.py @@ -10,6 +10,7 @@ from projects.models import (DOCUMENT_CLASSIFICATION, IMAGE_CLASSIFICATION, INTENT_DETECTION_AND_SLOT_FILLING, SEQ2SEQ, SEQUENCE_LABELING, SPEECH2TEXT, Member) from roles.models import Role +from roles.tests.utils import create_default_roles class ProjectData: @@ -35,12 +36,6 @@ class ProjectData: return [self.approver, self.annotator] -def create_default_roles(): - Role.objects.get_or_create(name=settings.ROLE_PROJECT_ADMIN) - Role.objects.get_or_create(name=settings.ROLE_ANNOTATOR) - Role.objects.get_or_create(name=settings.ROLE_ANNOTATION_APPROVER) - - def assign_user_to_role(project_member, project, role_name): role, _ = Role.objects.get_or_create(name=role_name) if Member.objects.filter(user=project_member, project=project).exists(): diff --git a/backend/projects/tests/test_project.py b/backend/projects/tests/test_project.py index 9b281cbb..e20e377a 100644 --- a/backend/projects/tests/test_project.py +++ b/backend/projects/tests/test_project.py @@ -1,7 +1,8 @@ from rest_framework import status from rest_framework.reverse import reverse -from api.tests.api.utils import CRUDMixin, create_default_roles, make_user, prepare_project +from api.tests.api.utils import CRUDMixin, make_user, prepare_project +from roles.tests.utils import create_default_roles class TestProjectList(CRUDMixin): diff --git a/backend/roles/tests/__init__.py b/backend/roles/tests/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/backend/roles/tests.py b/backend/roles/tests/test_views.py similarity index 84% rename from backend/roles/tests.py rename to backend/roles/tests/test_views.py index a14e29ae..a64ea06e 100644 --- a/backend/roles/tests.py +++ b/backend/roles/tests/test_views.py @@ -1,7 +1,8 @@ from rest_framework import status from rest_framework.reverse import reverse -from api.tests.api.utils import (CRUDMixin, create_default_roles, make_user) +from api.tests.api.utils import (CRUDMixin, make_user) +from .utils import create_default_roles class TestRoleAPI(CRUDMixin): diff --git a/backend/roles/tests/utils.py b/backend/roles/tests/utils.py new file mode 100644 index 00000000..ae0fb54f --- /dev/null +++ b/backend/roles/tests/utils.py @@ -0,0 +1,9 @@ +from django.conf import settings + +from roles.models import Role + + +def create_default_roles(): + Role.objects.get_or_create(name=settings.ROLE_PROJECT_ADMIN) + Role.objects.get_or_create(name=settings.ROLE_ANNOTATOR) + Role.objects.get_or_create(name=settings.ROLE_ANNOTATION_APPROVER)