Ticket #22050: defer_tests.py

File defer_tests.py, 1.1 KB (added by lovasb, 19 months ago)

Defer tests.py

Line 
1diff --git a/tests/defer/tests.py b/tests/defer/tests.py
2index 266a851..eaef66b 100644
3--- a/tests/defer/tests.py
4+++ b/tests/defer/tests.py
5@@ -3,7 +3,7 @@ from __future__ import unicode_literals
6 from django.db.models.query_utils import DeferredAttribute, InvalidQuery
7 from django.test import TestCase
8 
9-from .models import Secondary, Primary, Child, BigChild, ChildProxy
10+from .models import Secondary, Primary, Child, BigChild, ChildProxy, PrimaryProxy
11 
12 
13 class DeferTests(TestCase):
14@@ -169,6 +169,14 @@ class DeferTests(TestCase):
15         self.assertEqual(child.name, 'p1')
16         self.assertEqual(child.value, 'xx')
17 
18+    def test_defer_proxy_related_field(self):
19+        related = Secondary.objects.create(first='x1', second='x2')
20+        PrimaryProxy.objects.create(name='p1', value='xx', related=related)
21+        objs = PrimaryProxy.objects.all().select_related().only('related__first')
22+        self.assertEqual(len(objs), 1)
23+        obj = objs[0]
24+        self.assert_delayed(obj, 3)
25+
26     def test_defer_inheritance_pk_chaining(self):
27         """
28         When an inherited model is fetched from the DB, its PK is also fetched.
Back to Top