Skip to content

Commit 945d0b4

Browse files
committed
Extract _patch_project helper
1 parent 9f1bd5b commit 945d0b4

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

app/api/tests/test_api.py

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,19 @@ def remove_all_role_mappings():
2929
RoleMapping.objects.all().delete()
3030

3131

32+
class TestUtilsMixin:
33+
def _patch_project(self, project, attribute, value):
34+
old_value = getattr(project, attribute, None)
35+
setattr(project, attribute, value)
36+
project.save()
37+
38+
def cleanup_project():
39+
setattr(project, attribute, old_value)
40+
project.save()
41+
42+
self.addCleanup(cleanup_project)
43+
44+
3245
@override_settings(STATICFILES_STORAGE='django.contrib.staticfiles.storage.StaticFilesStorage')
3346
class TestProjectListAPI(APITestCase):
3447

@@ -604,7 +617,7 @@ def doCleanups(cls):
604617
remove_all_role_mappings()
605618

606619

607-
class TestAnnotationListAPI(APITestCase):
620+
class TestAnnotationListAPI(APITestCase, TestUtilsMixin):
608621

609622
@classmethod
610623
def setUpTestData(cls):

0 commit comments

Comments
 (0)