blob: 56cadcea969240c864cb7634834def148f6c2937 [file] [log] [blame]
Adrià Vilanova Martínezf19ea432024-01-23 20:20:52 +01001# 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.
Copybara854996b2021-09-07 19:36:02 +00004
5"""Unittests for monorail.project.projectupdates."""
6from __future__ import print_function
7from __future__ import division
8from __future__ import absolute_import
9
10import unittest
11
Adrià Vilanova Martínez9f9ade52022-10-10 23:20:11 +020012try:
13 from mox3 import mox
14except ImportError:
15 import mox
Copybara854996b2021-09-07 19:36:02 +000016
17from features import activities
18from project import projectupdates
19from services import service_manager
20from testing import fake
21from testing import testing_helpers
22
23
24class 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ínezf19ea432024-01-23 20:20:52 +010038 self.project_updates = projectupdates.ProjectUpdates(self.services)
Copybara854996b2021-09-07 19:36:02 +000039 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)