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