From 82bc7ee89e51d6af58cbb6bfd07ebd47aeae9b41 Mon Sep 17 00:00:00 2001 From: Jason Ward Date: Wed, 26 Sep 2012 16:10:20 -0400 Subject: [PATCH] refs #8: updated the tests to the correct expected number of queries --- authority/tests.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/authority/tests.py b/authority/tests.py index 8db8659..d9fc36a 100644 --- a/authority/tests.py +++ b/authority/tests.py @@ -214,6 +214,12 @@ class PerformanceTest(SmartCachingTestCase): self.user_check.has_user_perms('foo', self.user, True, False) self.user_check.has_user_perms('foo', self.user, True, False) + def test_has_user_perms_check_group(self): + # Regardless of the number groups permissions, it should only take one + # query to check both users and groups. + with self.assertNumQueries(1): + self.user_check.has_user_perms('foo', self.user, True, True) + def test_invalidate_permissions_cache(self): # Show that calling invalidate_permissions_cache will cause extra # queries. @@ -227,7 +233,7 @@ class PerformanceTest(SmartCachingTestCase): # One query to re generate the cache. self.user_check.has_user_perms('foo', self.user, True, False) - def test_has_user_perms_check_group(self): + def test_has_user_perms_check_group_multiple(self): # Create a permission with just a group. Permission.objects.create( content_type=Permission.objects.get_content_type(User), @@ -238,7 +244,7 @@ class PerformanceTest(SmartCachingTestCase): ) # Check the number of queries. - with self.assertNumQueries(2): + with self.assertNumQueries(1): self.user_check.has_user_perms('foo', self.user, True, True) # Create a second group. @@ -257,7 +263,7 @@ class PerformanceTest(SmartCachingTestCase): self.user_check.invalidate_permissions_cache() # Make sure it is the same number of queries. - with self.assertNumQueries(2): + with self.assertNumQueries(1): self.user_check.has_user_perms('foo', self.user, True, True)