* moves setupTestData in BaseAPITestCase class
This commit is contained in:
mpeltriaux 2022-01-27 15:32:31 +01:00
parent 1b0ab1be07
commit ea29aa7d6b
2 changed files with 33 additions and 16 deletions

View File

@ -0,0 +1,31 @@
"""
Author: Michel Peltriaux
Organization: Struktur- und Genehmigungsdirektion Nord, Rhineland-Palatinate, Germany
Contact: michel.peltriaux@sgdnord.rlp.de
Created on: 27.01.22
"""
from konova.settings import DEFAULT_GROUP
from konova.tests.test_views import BaseTestCase
class BaseAPIV1TestCase(BaseTestCase):
@classmethod
def setUpTestData(cls):
super().setUpTestData()
cls.superuser.get_API_token()
cls.superuser.api_token.is_active = True
cls.superuser.api_token.save()
default_group = cls.groups.get(name=DEFAULT_GROUP)
cls.superuser.groups.add(default_group)
cls.header_data = {
"HTTP_ksptoken": cls.superuser.api_token.token,
}
class APIV1CreateTestCase(BaseAPIV1TestCase):
@classmethod
def setUpTestData(cls):
super().setUpTestData()

View File

@ -2,30 +2,16 @@ import json
from django.urls import reverse from django.urls import reverse
from api.tests.v1.test_api_create import BaseAPIV1TestCase
from konova.settings import DEFAULT_GROUP from konova.settings import DEFAULT_GROUP
from konova.tests.test_views import BaseTestCase
from konova.utils.user_checks import is_default_group_only from konova.utils.user_checks import is_default_group_only
class APIV1SharingTestCase(BaseTestCase): class APIV1SharingTestCase(BaseAPIV1TestCase):
@classmethod @classmethod
def setUpTestData(cls): def setUpTestData(cls):
""" Creates a test file in memory for using in further tests
Returns:
"""
super().setUpTestData() super().setUpTestData()
cls.superuser.get_API_token()
cls.superuser.api_token.is_active = True
cls.superuser.api_token.save()
default_group = cls.groups.get(name=DEFAULT_GROUP)
cls.superuser.groups.add(default_group)
cls.header_data = {
"HTTP_ksptoken": cls.superuser.api_token.token,
}
def _run_share_request(self, url, user_list: list): def _run_share_request(self, url, user_list: list):
data = { data = {