diff --git a/tests/proxy_models/tests.py b/tests/proxy_models/tests.py
index 9824432..2210503 100644
a
|
b
|
from django.contrib.auth.models import User as AuthUser
|
8 | 8 | from django.contrib.contenttypes.models import ContentType |
9 | 9 | from django.core import checks, exceptions, management |
10 | 10 | from django.core.urlresolvers import reverse |
11 | | from django.db import DEFAULT_DB_ALIAS, models |
| 11 | from django.db import DEFAULT_DB_ALIAS, IntegrityError, models, transaction |
12 | 12 | from django.db.models import signals |
13 | | from django.test import TestCase, override_settings |
| 13 | from django.test import TestCase, TransactionTestCase, override_settings |
14 | 14 | |
15 | 15 | from .admin import admin as force_admin_model_registration # NOQA |
16 | 16 | from .models import ( |
… |
… |
class ProxyModelAdminTests(TestCase):
|
447 | 447 | delete_str = response.context['deleted_objects'][0] |
448 | 448 | self.assertEqual(delete_str, proxy_str) |
449 | 449 | self.client.logout() |
| 450 | |
| 451 | |
| 452 | class TransactionalProxyModelTests(TransactionTestCase): |
| 453 | available_apps = ['proxy_models'] |
| 454 | |
| 455 | def test_proxy_fk(self): |
| 456 | """ |
| 457 | Test that the DB contains proper foreign keys for proxy model references. |
| 458 | """ |
| 459 | @transaction.atomic |
| 460 | def create_failing_pk(): |
| 461 | t = TrackerUser.objects.create(status='bar') |
| 462 | proxy_tracker = ProxyTrackerUser.objects.get(pk=t.pk) |
| 463 | Improvement.objects.create( |
| 464 | summary='foof', version='foof', |
| 465 | reporter_id=1, associated_bug_id=1, |
| 466 | assignee=proxy_tracker, |
| 467 | ) |
| 468 | self.assertRaises(IntegrityError, create_failing_pk) |