Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(575)

Unified Diff: appengine/monorail/sitewide/test/usersettings_test.py

Issue 1868553004: Open Source Monorail (Closed) Base URL: https://chromium.googlesource.com/infra/infra.git@master
Patch Set: Rebase Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: appengine/monorail/sitewide/test/usersettings_test.py
diff --git a/appengine/monorail/sitewide/test/usersettings_test.py b/appengine/monorail/sitewide/test/usersettings_test.py
new file mode 100644
index 0000000000000000000000000000000000000000..faed83151decc8873e30db82e51c37cb281cdef0
--- /dev/null
+++ b/appengine/monorail/sitewide/test/usersettings_test.py
@@ -0,0 +1,66 @@
+# Copyright 2016 The Chromium Authors. All rights reserved.
+# Use of this source code is govered by a BSD-style
+# license that can be found in the LICENSE file or at
+# https://developers.google.com/open-source/licenses/bsd
+
+"""Tests for the user settings page."""
+
+import unittest
+
+import mox
+
+from framework import framework_helpers
+from framework import permissions
+from framework import template_helpers
+from proto import user_pb2
+from services import service_manager
+from sitewide import usersettings
+from testing import fake
+from testing import testing_helpers
+
+
+class UserSettingsTest(unittest.TestCase):
+
+ def setUp(self):
+ self.mox = mox.Mox()
+ self.services = service_manager.Services(user=fake.UserService())
+ self.servlet = usersettings.UserSettings(
+ 'req', 'res', services=self.services)
+
+ def tearDown(self):
+ self.mox.UnsetStubs()
+
+ def testAssertBasePermission(self):
+ mr = testing_helpers.MakeMonorailRequest()
+ mr.auth.user_id = 111L
+
+ # The following should return without exception.
+ self.servlet.AssertBasePermission(mr)
+
+ # No logged in user means anonymous access, should raise error.
+ mr.auth.user_id = 0L
+ self.assertRaises(permissions.PermissionException,
+ self.servlet.AssertBasePermission, mr)
+
+ def testGatherPageData(self):
+ self.mox.StubOutWithMock(
+ framework_helpers.UserSettings, 'GatherUnifiedSettingsPageData')
+ framework_helpers.UserSettings.GatherUnifiedSettingsPageData(
+ 0L, None, mox.IsA(user_pb2.User)).AndReturn({'unified': None})
+ self.mox.ReplayAll()
+
+ mr = testing_helpers.MakeMonorailRequest()
+ page_data = self.servlet.GatherPageData(mr)
+
+ self.assertItemsEqual(
+ ['logged_in_user_pb', 'unified', 'user_tab_mode',
+ 'viewed_user', 'offer_saved_queries_subtab', 'viewing_self'],
+ page_data.keys())
+ self.assertEqual(template_helpers.PBProxy(mr.auth.user_pb),
+ page_data['logged_in_user_pb'])
+
+ self.mox.VerifyAll()
+
+
+if __name__ == '__main__':
+ unittest.main()
« no previous file with comments | « appengine/monorail/sitewide/test/userprojects_test.py ('k') | appengine/monorail/sitewide/test/userupdates_test.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698