diff options
| author | Clément Escolano <clement.escolano@icloud.com> | 2023-08-01 23:31:40 +0200 |
|---|---|---|
| committer | Mariusz Felisiak <felisiak.mariusz@gmail.com> | 2023-09-18 13:23:21 +0200 |
| commit | cac94dd8aa2fb49cd2e06b5b37cf039257284bb0 (patch) | |
| tree | 5dda5f6607c0b3fa2cac9595f7b133aaa04b504d /tests/one_to_one | |
| parent | 190874eadd0c6dcaae0c244cc47e838cf0faf24d (diff) | |
Fixed #33651 -- Added support for prefetching GenericForeignKey.
Co-authored-by: revanthgss <revanthgss@almabase.com>
Co-authored-by: Mariusz Felisiak <felisiak.mariusz@gmail.com>
Diffstat (limited to 'tests/one_to_one')
| -rw-r--r-- | tests/one_to_one/tests.py | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/tests/one_to_one/tests.py b/tests/one_to_one/tests.py index 65efee6074..83644871fe 100644 --- a/tests/one_to_one/tests.py +++ b/tests/one_to_one/tests.py @@ -1,5 +1,6 @@ from django.db import IntegrityError, connection, transaction from django.test import TestCase +from django.utils.deprecation import RemovedInDjango60Warning from .models import ( Bar, @@ -606,3 +607,23 @@ class OneToOneTests(TestCase): self.b1.place_id = self.p2.pk self.b1.save() self.assertEqual(self.b1.place, self.p2) + + def test_get_prefetch_queryset_warning(self): + places = Place.objects.all() + msg = ( + "get_prefetch_queryset() is deprecated. Use get_prefetch_querysets() " + "instead." + ) + with self.assertWarnsMessage(RemovedInDjango60Warning, msg): + Place.bar.get_prefetch_queryset(places) + + def test_get_prefetch_querysets_invalid_querysets_length(self): + places = Place.objects.all() + msg = ( + "querysets argument of get_prefetch_querysets() should have a length of 1." + ) + with self.assertRaisesMessage(ValueError, msg): + Place.bar.get_prefetch_querysets( + instances=places, + querysets=[Bar.objects.all(), Bar.objects.all()], + ) |
