From 374a64acf8188c09cd247b7c67edcf98fa918fd7 Mon Sep 17 00:00:00 2001 From: Steve Howell Date: Mon, 30 Sep 2013 16:52:04 -0400 Subject: [PATCH] Add test for /activity page. For now we just verify that we don't explode, and we count the number of queries (25). (imported from commit 145c3373e2f6d005827af743729e03e524167904) --- zerver/tests.py | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/zerver/tests.py b/zerver/tests.py index bf70b080e1..f1912ed201 100644 --- a/zerver/tests.py +++ b/zerver/tests.py @@ -9,7 +9,7 @@ from django.db.models import Q from django.db.backends.util import CursorDebugWrapper from zerver.models import Message, UserProfile, Stream, Recipient, Subscription, \ - get_display_recipient, Realm, Client, \ + get_display_recipient, Realm, Client, UserActivity, \ PreregistrationUser, UserMessage, \ get_user_profile_by_email, email_to_domain, get_realm, get_stream from zerver.tornadoviews import json_get_updates, api_get_messages @@ -329,6 +329,26 @@ class AuthedTestCase(TestCase): return msg + +class ActivityTest(AuthedTestCase): + def test_activity(self): + self.login("hamlet@zulip.com") + client, _ = Client.objects.get_or_create(name='website') + query = '/json/update_pointer' + last_visit = datetime.datetime.now() + count=150 + for user_profile in UserProfile.objects.all(): + UserActivity.objects.get_or_create( + user_profile=user_profile, + client=client, + query=query, + count=count, + last_visit=last_visit + ) + with queries_captured() as queries: + self.client.get('/activity') + self.assertEqual(len(queries), 25) + class PublicURLTest(TestCase): """ Account creation URLs are accessible even when not logged in. Authenticated