Skip to content

Commit

Permalink
OpenConceptLab/ocl_issues#1336 | Speed up tests by getting rid of del…
Browse files Browse the repository at this point in the history
…ete_all and relying on rollback
  • Loading branch information
rkorytkowski committed Jul 14, 2022
1 parent fa8a898 commit 7d60010
Showing 1 changed file with 3 additions and 16 deletions.
19 changes: 3 additions & 16 deletions core/common/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
from requests.auth import HTTPBasicAuth
from rest_framework.test import APITestCase

from core.collections.models import Collection, CollectionReference
from core.common.constants import HEAD, OCL_ORG_ID, SUPER_ADMIN_USER_ID
from core.collections.models import CollectionReference
from core.common.constants import HEAD
from core.common.tasks import delete_s3_objects, bulk_import_parallel_inline
from core.common.utils import (
compact_dict_by_values, to_snake_case, flower_get, task_exists, parse_bulk_import_task_id,
Expand All @@ -25,25 +25,14 @@
get_resource_class_from_resource_name, flatten_dict, is_csv_file, is_url_encoded_string, to_parent_uri_from_kwargs,
set_current_user, get_current_user, set_request_url, get_request_url, nested_dict_values, chunks, api_get,
split_list_by_condition)
from core.concepts.models import Concept, LocalizedText
from core.mappings.models import Mapping
from core.concepts.models import Concept
from core.orgs.models import Organization
from core.sources.models import Source
from core.users.models import UserProfile
from core.users.tests.factories import UserProfileFactory
from .services import S3, PostgresQL


def delete_all():
Collection.objects.all().delete()
Mapping.objects.all().delete()
Concept.objects.all().delete()
LocalizedText.objects.all().delete()
Source.objects.all().delete()
Organization.objects.exclude(id=OCL_ORG_ID).all().delete()
UserProfile.objects.exclude(id=SUPER_ADMIN_USER_ID).all().delete()


class CustomTestRunner(ColourRunnerMixin, DiscoverRunner):
pass

Expand Down Expand Up @@ -214,7 +203,6 @@ def setUpClass(cls):

def tearDown(self):
super().tearDown()
delete_all()


class OCLTestCase(TestCase, BaseTestCase):
Expand All @@ -226,7 +214,6 @@ def setUpClass(cls):

def tearDown(self):
super().tearDown()
delete_all()


class S3Test(TestCase):
Expand Down

0 comments on commit 7d60010

Please sign in to comment.