From 945d0b412ed893ac8e18b483a096a039d4af958f Mon Sep 17 00:00:00 2001 From: Clemens Wolff Date: Mon, 6 Jan 2020 15:42:51 -0500 Subject: [PATCH] Extract _patch_project helper --- app/api/tests/test_api.py | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/app/api/tests/test_api.py b/app/api/tests/test_api.py index ed5cf843..dfb6403c 100644 --- a/app/api/tests/test_api.py +++ b/app/api/tests/test_api.py @@ -29,6 +29,19 @@ def remove_all_role_mappings(): RoleMapping.objects.all().delete() +class TestUtilsMixin: + def _patch_project(self, project, attribute, value): + old_value = getattr(project, attribute, None) + setattr(project, attribute, value) + project.save() + + def cleanup_project(): + setattr(project, attribute, old_value) + project.save() + + self.addCleanup(cleanup_project) + + @override_settings(STATICFILES_STORAGE='django.contrib.staticfiles.storage.StaticFilesStorage') class TestProjectListAPI(APITestCase): @@ -604,7 +617,7 @@ class TestApproveLabelsAPI(APITestCase): remove_all_role_mappings() -class TestAnnotationListAPI(APITestCase): +class TestAnnotationListAPI(APITestCase, TestUtilsMixin): @classmethod def setUpTestData(cls):