blob: e4c5cea9c7852fa8641b65713544c5d3dcf1b435 [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
Adrià Vilanova Martínez9f9ade52022-10-10 23:20:11 +020013try:
14 from mox3 import mox
15except ImportError:
16 import mox
Copybara854996b2021-09-07 19:36:02 +000017
18from features import activities
19from project import projectupdates
20from services import service_manager
21from testing import fake
22from testing import testing_helpers
23
24
25class 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)