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

Side by Side 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 unified diff | Download patch
OLDNEW
(Empty)
1 # Copyright 2016 The Chromium Authors. All rights reserved.
2 # Use of this source code is govered by a BSD-style
3 # license that can be found in the LICENSE file or at
4 # https://developers.google.com/open-source/licenses/bsd
5
6 """Tests for the user settings page."""
7
8 import unittest
9
10 import mox
11
12 from framework import framework_helpers
13 from framework import permissions
14 from framework import template_helpers
15 from proto import user_pb2
16 from services import service_manager
17 from sitewide import usersettings
18 from testing import fake
19 from testing import testing_helpers
20
21
22 class UserSettingsTest(unittest.TestCase):
23
24 def setUp(self):
25 self.mox = mox.Mox()
26 self.services = service_manager.Services(user=fake.UserService())
27 self.servlet = usersettings.UserSettings(
28 'req', 'res', services=self.services)
29
30 def tearDown(self):
31 self.mox.UnsetStubs()
32
33 def testAssertBasePermission(self):
34 mr = testing_helpers.MakeMonorailRequest()
35 mr.auth.user_id = 111L
36
37 # The following should return without exception.
38 self.servlet.AssertBasePermission(mr)
39
40 # No logged in user means anonymous access, should raise error.
41 mr.auth.user_id = 0L
42 self.assertRaises(permissions.PermissionException,
43 self.servlet.AssertBasePermission, mr)
44
45 def testGatherPageData(self):
46 self.mox.StubOutWithMock(
47 framework_helpers.UserSettings, 'GatherUnifiedSettingsPageData')
48 framework_helpers.UserSettings.GatherUnifiedSettingsPageData(
49 0L, None, mox.IsA(user_pb2.User)).AndReturn({'unified': None})
50 self.mox.ReplayAll()
51
52 mr = testing_helpers.MakeMonorailRequest()
53 page_data = self.servlet.GatherPageData(mr)
54
55 self.assertItemsEqual(
56 ['logged_in_user_pb', 'unified', 'user_tab_mode',
57 'viewed_user', 'offer_saved_queries_subtab', 'viewing_self'],
58 page_data.keys())
59 self.assertEqual(template_helpers.PBProxy(mr.auth.user_pb),
60 page_data['logged_in_user_pb'])
61
62 self.mox.VerifyAll()
63
64
65 if __name__ == '__main__':
66 unittest.main()
OLDNEW
« 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