Exemple #1
0
 def test_user_set_is_cached(self):
     f = TenantFlagFactory()
     f.users.add(self.user)
     f.save()
     with self.assertNumQueries(2):
         self.assertTrue(f.is_active(self.request))
     with self.assertNumQueries(0):
         self.assertTrue(f.is_active(self.request))
Exemple #2
0
 def test_group_set_is_cached(self):
     f = TenantFlagFactory()
     group = GroupFactory()
     f.groups.add(group)
     f.save()
     self.user.groups.add(group)
     with self.assertNumQueries(4):
         self.assertTrue(f.is_active(self.request))
     with self.assertNumQueries(1):
         # we still need to query the user's list of groups
         self.assertTrue(f.is_active(self.request))