blob: 56cadcea969240c864cb7634834def148f6c2937 [file] [log] [blame]
# Copyright 2016 The Chromium Authors
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
"""Unittests for monorail.project.projectupdates."""
from __future__ import print_function
from __future__ import division
from __future__ import absolute_import
import unittest
try:
from mox3 import mox
except ImportError:
import mox
from features import activities
from project import projectupdates
from services import service_manager
from testing import fake
from testing import testing_helpers
class ProjectUpdatesTest(unittest.TestCase):
def setUp(self):
self.services = service_manager.Services(project=fake.ProjectService())
self.project_name = 'proj'
self.project_id = 987
self.project = self.services.project.TestAddProject(
self.project_name, project_id=self.project_id,
process_inbound_email=True)
self.mr = testing_helpers.MakeMonorailRequest(
services=self.services, project=self.project)
self.mr.project_name = self.project_name
self.project_updates = projectupdates.ProjectUpdates(self.services)
self.mox = mox.Mox()
def tearDown(self):
self.mox.UnsetStubs()
self.mox.ResetAll()
def testGatherPageData(self):
self.mox.StubOutWithMock(activities, 'GatherUpdatesData')
activities.GatherUpdatesData(
self.services, self.mr, project_ids=[self.project_id],
ending='by_user',
updates_page_url='/p/%s/updates/list' % self.project_name,
autolink=self.services.autolink).AndReturn({'test': 'testing'})
self.mox.ReplayAll()
page_data = self.project_updates.GatherPageData(self.mr)
self.mox.VerifyAll()
self.assertEqual(
{
'subtab_mode': None,
'user_updates_tab_mode': None,
'test': 'testing'
}, page_data)