blob: c2542e8f3afa4c0ef411b4b3a20844e9f65ae605 [file] [log] [blame]
Copybara854996b2021-09-07 19:36:02 +00001# 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."""
7from __future__ import print_function
8from __future__ import division
9from __future__ import absolute_import
10
11import unittest
12
13import mox
14
15from features import activities
16from project import projectupdates
17from services import service_manager
18from testing import fake
19from testing import testing_helpers
20
21
22class ProjectUpdatesTest(unittest.TestCase):
23
24 def setUp(self):
25 self.services = service_manager.Services(project=fake.ProjectService())
26
27 self.project_name = 'proj'
28 self.project_id = 987
29 self.project = self.services.project.TestAddProject(
30 self.project_name, project_id=self.project_id,
31 process_inbound_email=True)
32
33 self.mr = testing_helpers.MakeMonorailRequest(
34 services=self.services, project=self.project)
35 self.mr.project_name = self.project_name
36 self.project_updates = projectupdates.ProjectUpdates(
37 None, None, self.services)
38 self.mox = mox.Mox()
39
40 def tearDown(self):
41 self.mox.UnsetStubs()
42 self.mox.ResetAll()
43
44 def testGatherPageData(self):
45 self.mox.StubOutWithMock(activities, 'GatherUpdatesData')
46 activities.GatherUpdatesData(
47 self.services, self.mr, project_ids=[self.project_id],
48 ending='by_user',
49 updates_page_url='/p/%s/updates/list' % self.project_name,
50 autolink=self.services.autolink).AndReturn({'test': 'testing'})
51 self.mox.ReplayAll()
52
53 page_data = self.project_updates.GatherPageData(self.mr)
54 self.mox.VerifyAll()
55 self.assertEqual(
56 {
57 'subtab_mode': None,
58 'user_updates_tab_mode': None,
59 'test': 'testing'
60 }, page_data)