summaryrefslogtreecommitdiffstats
path: root/askbot/tests/cache_tests.py
diff options
context:
space:
mode:
authorEvgeny Fadeev <evgeny.fadeev@gmail.com>2011-11-16 23:03:40 -0300
committerEvgeny Fadeev <evgeny.fadeev@gmail.com>2011-11-16 23:03:40 -0300
commita1773f4a71601295f0c6f9fbcff476a73dcc0623 (patch)
treeb3e977faf311e721f28ccfb276ebda177de246b5 /askbot/tests/cache_tests.py
parent2278a0404e2d12dddd46b063f90c99f3b4857ffa (diff)
downloadaskbot-a1773f4a71601295f0c6f9fbcff476a73dcc0623.tar.gz
askbot-a1773f4a71601295f0c6f9fbcff476a73dcc0623.tar.bz2
askbot-a1773f4a71601295f0c6f9fbcff476a73dcc0623.zip
separated cache tests into new file and disabled misc tests, whose purpose is unclear
Diffstat (limited to 'askbot/tests/cache_tests.py')
-rw-r--r--askbot/tests/cache_tests.py43
1 files changed, 43 insertions, 0 deletions
diff --git a/askbot/tests/cache_tests.py b/askbot/tests/cache_tests.py
new file mode 100644
index 00000000..5eda8c74
--- /dev/null
+++ b/askbot/tests/cache_tests.py
@@ -0,0 +1,43 @@
+from django.db import connection
+from django.core.urlresolvers import reverse
+from django.conf import settings
+from askbot.tests.utils import AskbotTestCase
+
+class CacheTests(AskbotTestCase):
+ def setUp(self):
+ self.create_user()
+ self.create_user('other_user')
+ self.question = self.post_question()
+ self.post_answer(question = self.question)
+ settings.DEBUG = True # because it's forsed to False
+
+ def visit_question(self):
+ self.client.get(self.question.get_absolute_url(), follow=True)
+
+ def test_anonymous_question_cache(self):
+
+ self.visit_question()
+ counter = len(connection.queries)
+ print 'we have %d queries' % counter
+ self.visit_question()
+
+ #second hit to the same question should give fewer queries
+ self.assertTrue(counter > len(connection.queries))
+ settings.DEBUG = False
+
+ def test_authentificated_no_question_cache(self):
+ url = reverse('question', kwargs={'id': self.question.id})
+
+ password = '123'
+ self.other_user.set_password(password)
+ self.client.login(username=self.other_user.username, password=password)
+
+ self.visit_question()
+ counter = len(connection.queries)
+ self.visit_question()
+
+ #expect the same number of queries both times
+ self.assertEqual(counter, len(connection.queries))
+ settings.DEBUG = False
+
+