Copybara | 854996b | 2021-09-07 19:36:02 +0000 | [diff] [blame] | 1 | # Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 | # Use of this source code is governed 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 | """Unittests for monorail.project.projectupdates.""" |
| 7 | from __future__ import print_function |
| 8 | from __future__ import division |
| 9 | from __future__ import absolute_import |
| 10 | |
| 11 | import unittest |
| 12 | |
Adrià Vilanova MartÃnez | 9f9ade5 | 2022-10-10 23:20:11 +0200 | [diff] [blame^] | 13 | try: |
| 14 | from mox3 import mox |
| 15 | except ImportError: |
| 16 | import mox |
Copybara | 854996b | 2021-09-07 19:36:02 +0000 | [diff] [blame] | 17 | |
| 18 | from features import activities |
| 19 | from project import projectupdates |
| 20 | from services import service_manager |
| 21 | from testing import fake |
| 22 | from testing import testing_helpers |
| 23 | |
| 24 | |
| 25 | class ProjectUpdatesTest(unittest.TestCase): |
| 26 | |
| 27 | def setUp(self): |
| 28 | self.services = service_manager.Services(project=fake.ProjectService()) |
| 29 | |
| 30 | self.project_name = 'proj' |
| 31 | self.project_id = 987 |
| 32 | self.project = self.services.project.TestAddProject( |
| 33 | self.project_name, project_id=self.project_id, |
| 34 | process_inbound_email=True) |
| 35 | |
| 36 | self.mr = testing_helpers.MakeMonorailRequest( |
| 37 | services=self.services, project=self.project) |
| 38 | self.mr.project_name = self.project_name |
| 39 | self.project_updates = projectupdates.ProjectUpdates( |
| 40 | None, None, self.services) |
| 41 | self.mox = mox.Mox() |
| 42 | |
| 43 | def tearDown(self): |
| 44 | self.mox.UnsetStubs() |
| 45 | self.mox.ResetAll() |
| 46 | |
| 47 | def testGatherPageData(self): |
| 48 | self.mox.StubOutWithMock(activities, 'GatherUpdatesData') |
| 49 | activities.GatherUpdatesData( |
| 50 | self.services, self.mr, project_ids=[self.project_id], |
| 51 | ending='by_user', |
| 52 | updates_page_url='/p/%s/updates/list' % self.project_name, |
| 53 | autolink=self.services.autolink).AndReturn({'test': 'testing'}) |
| 54 | self.mox.ReplayAll() |
| 55 | |
| 56 | page_data = self.project_updates.GatherPageData(self.mr) |
| 57 | self.mox.VerifyAll() |
| 58 | self.assertEqual( |
| 59 | { |
| 60 | 'subtab_mode': None, |
| 61 | 'user_updates_tab_mode': None, |
| 62 | 'test': 'testing' |
| 63 | }, page_data) |