summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorSimon Charette <charette.s@gmail.com>2017-01-10 13:50:20 -0500
committerSimon Charette <charette.s@gmail.com>2017-01-13 10:02:01 -0500
commit4e48cfc108c6cf69052cc728e72dc2cb25a880a5 (patch)
tree90c62a2df9a0e3074474fa4cb46f061405728503 /tests
parentede59ef6f39ff8a6443c2b24df0208ef6ec41ee0 (diff)
Fixed #27709 -- Fixed get_for_models() for proxies with an empty cache.
Thanks Peter Inglesby for the report and tests.
Diffstat (limited to 'tests')
-rw-r--r--tests/contenttypes_tests/test_models.py15
1 files changed, 14 insertions, 1 deletions
diff --git a/tests/contenttypes_tests/test_models.py b/tests/contenttypes_tests/test_models.py
index cf0c188fa8..a51a343c83 100644
--- a/tests/contenttypes_tests/test_models.py
+++ b/tests/contenttypes_tests/test_models.py
@@ -54,13 +54,26 @@ class ContentTypesTests(TestCase):
with self.assertNumQueries(0):
ContentType.objects.get_by_natural_key('contenttypes', 'contenttype')
+ def test_get_for_models_creation(self):
+ ContentType.objects.all().delete()
+ with self.assertNumQueries(4):
+ cts = ContentType.objects.get_for_models(ContentType, FooWithUrl, ProxyModel, ConcreteModel)
+ self.assertEqual(cts, {
+ ContentType: ContentType.objects.get_for_model(ContentType),
+ FooWithUrl: ContentType.objects.get_for_model(FooWithUrl),
+ ProxyModel: ContentType.objects.get_for_model(ProxyModel),
+ ConcreteModel: ContentType.objects.get_for_model(ConcreteModel),
+ })
+
def test_get_for_models_empty_cache(self):
# Empty cache.
with self.assertNumQueries(1):
- cts = ContentType.objects.get_for_models(ContentType, FooWithUrl)
+ cts = ContentType.objects.get_for_models(ContentType, FooWithUrl, ProxyModel, ConcreteModel)
self.assertEqual(cts, {
ContentType: ContentType.objects.get_for_model(ContentType),
FooWithUrl: ContentType.objects.get_for_model(FooWithUrl),
+ ProxyModel: ContentType.objects.get_for_model(ProxyModel),
+ ConcreteModel: ContentType.objects.get_for_model(ConcreteModel),
})
def test_get_for_models_partial_cache(self):