mirror of
https://github.com/Hopiu/django-cachalot.git
synced 2026-05-09 05:04:55 +00:00
Moves a test method.
This commit is contained in:
parent
67c05ed460
commit
cd278aea75
1 changed files with 28 additions and 28 deletions
|
|
@ -299,34 +299,6 @@ class WriteTestCase(TransactionTestCase):
|
|||
self.assertListEqual(data5, [user1, user2])
|
||||
self.assertListEqual([u.n for u in data5], [3, 2])
|
||||
|
||||
def test_invalidate_having(self):
|
||||
with self.assertNumQueries(1):
|
||||
data1 = list(User.objects.annotate(n=Count('user_permissions'))
|
||||
.filter(n__gte=1))
|
||||
self.assertListEqual(data1, [])
|
||||
|
||||
u = User.objects.create_user('user')
|
||||
|
||||
with self.assertNumQueries(1):
|
||||
data2 = list(User.objects.annotate(n=Count('user_permissions'))
|
||||
.filter(n__gte=1))
|
||||
self.assertListEqual(data2, [])
|
||||
|
||||
p = Permission.objects.first()
|
||||
p.save()
|
||||
|
||||
with self.assertNumQueries(1):
|
||||
data3 = list(User.objects.annotate(n=Count('user_permissions'))
|
||||
.filter(n__gte=1))
|
||||
self.assertListEqual(data3, [])
|
||||
|
||||
u.user_permissions.add(p)
|
||||
|
||||
with self.assertNumQueries(1):
|
||||
data3 = list(User.objects.annotate(n=Count('user_permissions'))
|
||||
.filter(n__gte=1))
|
||||
self.assertListEqual(data3, [u])
|
||||
|
||||
def test_invalidate_subquery(self):
|
||||
with self.assertNumQueries(1):
|
||||
data1 = list(Test.objects.filter(owner__in=User.objects.all()))
|
||||
|
|
@ -575,6 +547,34 @@ class WriteTestCase(TransactionTestCase):
|
|||
self.assertListEqual(data4, [t1, t2])
|
||||
self.assertListEqual([o.username_length for o in data4], [4, 5])
|
||||
|
||||
def test_invalidate_having(self):
|
||||
with self.assertNumQueries(1):
|
||||
data1 = list(User.objects.annotate(n=Count('user_permissions'))
|
||||
.filter(n__gte=1))
|
||||
self.assertListEqual(data1, [])
|
||||
|
||||
u = User.objects.create_user('user')
|
||||
|
||||
with self.assertNumQueries(1):
|
||||
data2 = list(User.objects.annotate(n=Count('user_permissions'))
|
||||
.filter(n__gte=1))
|
||||
self.assertListEqual(data2, [])
|
||||
|
||||
p = Permission.objects.first()
|
||||
p.save()
|
||||
|
||||
with self.assertNumQueries(1):
|
||||
data3 = list(User.objects.annotate(n=Count('user_permissions'))
|
||||
.filter(n__gte=1))
|
||||
self.assertListEqual(data3, [])
|
||||
|
||||
u.user_permissions.add(p)
|
||||
|
||||
with self.assertNumQueries(1):
|
||||
data3 = list(User.objects.annotate(n=Count('user_permissions'))
|
||||
.filter(n__gte=1))
|
||||
self.assertListEqual(data3, [u])
|
||||
|
||||
def test_invalidate_extra_where(self):
|
||||
sql_condition = ("owner_id IN "
|
||||
"(SELECT id FROM auth_user WHERE username = 'admin')")
|
||||
|
|
|
|||
Loading…
Reference in a new issue