OLD | NEW |
(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 """Unit tests for savedqueries feature.""" |
| 7 |
| 8 import unittest |
| 9 |
| 10 from features import savedqueries |
| 11 from framework import monorailrequest |
| 12 from framework import permissions |
| 13 from services import service_manager |
| 14 from testing import fake |
| 15 |
| 16 |
| 17 class SavedQueriesTest(unittest.TestCase): |
| 18 |
| 19 def setUp(self): |
| 20 self.services = service_manager.Services( |
| 21 user=fake.UserService()) |
| 22 self.servlet = savedqueries.SavedQueries( |
| 23 'req', 'res', services=self.services) |
| 24 self.services.user.TestAddUser('a@example.com', 111L) |
| 25 |
| 26 def testAssertBasePermission(self): |
| 27 """Only permit site admins and users viewing themselves.""" |
| 28 mr = monorailrequest.MonorailRequest() |
| 29 mr.viewed_user_auth.user_id = 111L |
| 30 mr.auth.user_id = 222L |
| 31 |
| 32 self.assertRaises(permissions.PermissionException, |
| 33 self.servlet.AssertBasePermission, mr) |
| 34 |
| 35 mr.auth.user_id = 111L |
| 36 self.servlet.AssertBasePermission(mr) |
| 37 |
| 38 mr.auth.user_id = 222L |
| 39 mr.auth.user_pb.is_site_admin = True |
| 40 self.servlet.AssertBasePermission(mr) |
OLD | NEW |