|
4 | 4 |
|
5 | 5 | from lxml import etree
|
6 | 6 |
|
| 7 | +from django.contrib.contenttypes.models import ContentType |
7 | 8 | from django.core.urlresolvers import reverse
|
8 | 9 | from django.test import TransactionTestCase
|
9 | 10 |
|
10 | 11 | from editorsnotes.main import models as main_models
|
11 |
| -from editorsnotes.main.management import update_project_permissions |
12 | 12 | from editorsnotes.search import en_index, activity_index
|
13 | 13 |
|
14 | 14 | def flush_es_indexes():
|
@@ -58,13 +58,21 @@ def delete_es_indexes():
|
58 | 58 | BAD_PERMISSION_MESSAGE = u'You do not have permission to perform this action.'
|
59 | 59 | NO_AUTHENTICATION_MESSAGE = u'Authentication credentials were not provided.'
|
60 | 60 |
|
61 |
| -class TopicAPITestCase(TransactionTestCase): |
| 61 | +class ClearContentTypesTransactionTestCase(TransactionTestCase): |
| 62 | + """ |
| 63 | + See https://code.djangoproject.com/ticket/10827 |
| 64 | + """ |
| 65 | + def _pre_setup(self, *args, **kwargs): |
| 66 | + ContentType.objects.clear_cache() |
| 67 | + super(ClearContentTypesTransactionTestCase, self)._pre_setup(*args, **kwargs) |
| 68 | + |
| 69 | + |
| 70 | +class TopicAPITestCase(ClearContentTypesTransactionTestCase): |
62 | 71 | fixtures = ['projects.json']
|
63 | 72 | def setUp(self):
|
64 | 73 | self.user = main_models.User.objects.get(username='barry')
|
65 | 74 | self.project = main_models.Project.objects.get(slug='emma')
|
66 | 75 | self.client.login(username='barry', password='barry')
|
67 |
| - update_project_permissions() |
68 | 76 |
|
69 | 77 | def create_test_topic(self):
|
70 | 78 | data = TEST_TOPIC
|
@@ -247,13 +255,12 @@ def test_topic_api_delete_logged_out(self):
|
247 | 255 | self.assertEqual(response.data['detail'], NO_AUTHENTICATION_MESSAGE)
|
248 | 256 |
|
249 | 257 |
|
250 |
| -class DocumentAPITestCase(TransactionTestCase): |
| 258 | +class DocumentAPITestCase(ClearContentTypesTransactionTestCase): |
251 | 259 | fixtures = ['projects.json']
|
252 | 260 | def setUp(self):
|
253 | 261 | self.user = main_models.User.objects.get(username='barry')
|
254 | 262 | self.project = main_models.Project.objects.get(slug='emma')
|
255 | 263 | self.client.login(username='barry', password='barry')
|
256 |
| - update_project_permissions() |
257 | 264 |
|
258 | 265 | def create_test_document(self):
|
259 | 266 | data = TEST_DOCUMENT
|
@@ -425,13 +432,12 @@ def test_document_api_delete_logged_out(self):
|
425 | 432 | self.assertEqual(response.data['detail'], NO_AUTHENTICATION_MESSAGE)
|
426 | 433 |
|
427 | 434 |
|
428 |
| -class NoteAPITestCase(TransactionTestCase): |
| 435 | +class NoteAPITestCase(ClearContentTypesTransactionTestCase): |
429 | 436 | fixtures = ['projects.json']
|
430 | 437 | def setUp(self):
|
431 | 438 | self.user = main_models.User.objects.get(username='barry')
|
432 | 439 | self.project = main_models.Project.objects.get(slug='emma')
|
433 | 440 | self.client.login(username='barry', password='barry')
|
434 |
| - update_project_permissions() |
435 | 441 |
|
436 | 442 | def create_test_note(self):
|
437 | 443 | data = TEST_NOTE
|
|
0 commit comments