10 | 10 | from models import MyPersonProxy, Abstract, OtherPerson, User, UserProxy |
11 | 11 | from models import UserProxyProxy, Country, State, StateProxy, TrackerUser |
12 | 12 | from models import BaseUser, Bug, ProxyTrackerUser, Improvement, ProxyProxyBug |
| 315 | |
| 316 | def test_delete_cascade_to_proxy_objects(self): |
| 317 | """ |
| 318 | Test that delete() cascades to proxy objects. Regression for #16128. |
| 319 | """ |
| 320 | # delete with a foreign key on a regular model |
| 321 | joe = TrackerUser.objects.create(name='Regular Joe', status='contrib') |
| 322 | joe_s_issue = Issue.objects.create(summary='deep magic', assignee=joe) |
| 323 | self.assertEqual(Issue.objects.count(), 1) |
| 324 | joe.delete() |
| 325 | self.assertEqual(Issue.objects.count(), 0) |
| 326 | # delete with a foreign key on a proxy model |
| 327 | joe = ProxyTrackerUser.objects.create(name='Proxy Joe', status='contrib') |
| 328 | joe_s_issue = IssueWithProxy.objects.create(summary='deeper magic', assignee=joe) |
| 329 | self.assertEqual(IssueWithProxy.objects.count(), 1) |
| 330 | joe.delete() |
| 331 | self.assertEqual(IssueWithProxy.objects.count(), 0) |