Merge branch 'main' into avm99963-monorail
Merged commit 34d8229ae2b51fb1a15bd208e6fe6185c94f6266
GitOrigin-RevId: 7ee0917f93a577e475f8e09526dd144d245593f4
diff --git a/sitewide/test/custom_404_test.py b/sitewide/test/custom_404_test.py
index b47501d..fe099d6 100644
--- a/sitewide/test/custom_404_test.py
+++ b/sitewide/test/custom_404_test.py
@@ -1,7 +1,6 @@
-# Copyright 2017 The Chromium Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style
-# license that can be found in the LICENSE file or at
-# https://developers.google.com/open-source/licenses/bsd
+# Copyright 2017 The Chromium Authors
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
"""Unit tests for the custom_404 servlet."""
from __future__ import print_function
@@ -23,7 +22,7 @@
def setUp(self):
self.services = service_manager.Services(
project=fake.ProjectService())
- self.servlet = custom_404.ErrorPage('req', 'res', services=self.services)
+ self.servlet = custom_404.ErrorPage(services=self.services)
def testGatherPageData_NoProjectSpecified(self):
"""Project was not included in URL, so raise exception, will cause 400."""
diff --git a/sitewide/test/group_helpers_test.py b/sitewide/test/group_helpers_test.py
index af03d08..02ecfbd 100644
--- a/sitewide/test/group_helpers_test.py
+++ b/sitewide/test/group_helpers_test.py
@@ -1,7 +1,6 @@
-# Copyright 2016 The Chromium Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style
-# license that can be found in the LICENSE file or at
-# https://developers.google.com/open-source/licenses/bsd
+# 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.
"""Unit test for User Group helpers."""
from __future__ import print_function
@@ -10,8 +9,8 @@
import unittest
-from proto import user_pb2
-from proto import usergroup_pb2
+from mrproto import user_pb2
+from mrproto import usergroup_pb2
from sitewide import group_helpers
diff --git a/sitewide/test/groupadmin_test.py b/sitewide/test/groupadmin_test.py
index 72dfa9d..1322a0f 100644
--- a/sitewide/test/groupadmin_test.py
+++ b/sitewide/test/groupadmin_test.py
@@ -1,7 +1,6 @@
-# Copyright 2016 The Chromium Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style
-# license that can be found in the LICENSE file or at
-# https://developers.google.com/open-source/licenses/bsd
+# 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.
"""Unit test for User Group admin servlet."""
from __future__ import print_function
@@ -11,7 +10,7 @@
import unittest
from framework import permissions
-from proto import usergroup_pb2
+from mrproto import usergroup_pb2
from services import service_manager
from sitewide import groupadmin
from testing import fake
diff --git a/sitewide/test/groupcreate_test.py b/sitewide/test/groupcreate_test.py
index f82fb74..2944d11 100644
--- a/sitewide/test/groupcreate_test.py
+++ b/sitewide/test/groupcreate_test.py
@@ -1,7 +1,6 @@
-# Copyright 2016 The Chromium Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style
-# license that can be found in the LICENSE file or at
-# https://developers.google.com/open-source/licenses/bsd
+# 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.
"""Unit test for User Group creation servlet."""
from __future__ import print_function
@@ -12,8 +11,8 @@
import settings
from framework import permissions
-from proto import site_pb2
-from proto import usergroup_pb2
+from mrproto import site_pb2
+from mrproto import usergroup_pb2
from services import service_manager
from sitewide import groupcreate
from testing import fake
diff --git a/sitewide/test/groupdetail_test.py b/sitewide/test/groupdetail_test.py
index f294606..dc341ee 100644
--- a/sitewide/test/groupdetail_test.py
+++ b/sitewide/test/groupdetail_test.py
@@ -1,7 +1,6 @@
-# Copyright 2016 The Chromium Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style
-# license that can be found in the LICENSE file or at
-# https://developers.google.com/open-source/licenses/bsd
+# 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.
"""Unit test for User Group Detail servlet."""
from __future__ import print_function
diff --git a/sitewide/test/grouplist_test.py b/sitewide/test/grouplist_test.py
index 9ec6bd5..9f838a5 100644
--- a/sitewide/test/grouplist_test.py
+++ b/sitewide/test/grouplist_test.py
@@ -1,7 +1,6 @@
-# Copyright 2016 The Chromium Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style
-# license that can be found in the LICENSE file or at
-# https://developers.google.com/open-source/licenses/bsd
+# 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.
"""Unit test for User Group List servlet."""
from __future__ import print_function
@@ -25,7 +24,7 @@
def setUp(self):
self.services = service_manager.Services(
usergroup=fake.UserGroupService())
- self.servlet = grouplist.GroupList('req', 'res', services=self.services)
+ self.servlet = grouplist.GroupList(services=self.services)
self.mr = testing_helpers.MakeMonorailRequest()
self.testbed = testbed.Testbed()
self.testbed.activate()
diff --git a/sitewide/test/hostinghome_test.py b/sitewide/test/hostinghome_test.py
index de125a5..8a486f8 100644
--- a/sitewide/test/hostinghome_test.py
+++ b/sitewide/test/hostinghome_test.py
@@ -1,7 +1,6 @@
-# Copyright 2016 The Chromium Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style
-# license that can be found in the LICENSE file or at
-# https://developers.google.com/open-source/licenses/bsd
+# 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.
"""Tests for the Monorail home page."""
from __future__ import print_function
@@ -15,8 +14,8 @@
import settings
from framework import permissions
-from proto import project_pb2
-from proto import site_pb2
+from mrproto import project_pb2
+from mrproto import site_pb2
from services import service_manager
from sitewide import hostinghome
from sitewide import projectsearch
diff --git a/sitewide/test/moved_test.py b/sitewide/test/moved_test.py
index eccb195..2f4ee4f 100644
--- a/sitewide/test/moved_test.py
+++ b/sitewide/test/moved_test.py
@@ -1,17 +1,15 @@
-# Copyright 2016 The Chromium Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style
-# license that can be found in the LICENSE file or at
-# https://developers.google.com/open-source/licenses/bsd
+# 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.
"""Unit tests for the moved project notification page servlet."""
from __future__ import print_function
from __future__ import division
from __future__ import absolute_import
+import six
import unittest
-import webapp2
-
from framework import exceptions
from services import service_manager
from sitewide import moved
@@ -62,9 +60,8 @@
path='/hosting/moved?project=%s' % self.old_project)
page_data = self.servlet.GatherPageData(mr)
- self.assertItemsEqual(
- ['project_name', 'moved_to_url'],
- list(page_data.keys()))
+ six.assertCountEqual(
+ self, ['project_name', 'moved_to_url'], list(page_data.keys()))
self.assertEqual(self.old_project, page_data['project_name'])
self.assertEqual('https://other-tracker.bugs', page_data['moved_to_url'])
@@ -76,9 +73,8 @@
path='/hosting/moved?project=%s' % self.old_project)
page_data = self.servlet.GatherPageData(mr)
- self.assertItemsEqual(
- ['project_name', 'moved_to_url'],
- list(page_data.keys()))
+ six.assertCountEqual(
+ self, ['project_name', 'moved_to_url'], list(page_data.keys()))
self.assertEqual(self.old_project, page_data['project_name'])
self.assertEqual('http://127.0.0.1/p/new-project/',
page_data['moved_to_url'])
@@ -91,9 +87,8 @@
path='/hosting/moved?project=%s' % self.old_project)
page_data = self.servlet.GatherPageData(mr)
- self.assertItemsEqual(
- ['project_name', 'moved_to_url'],
- list(page_data.keys()))
+ six.assertCountEqual(
+ self, ['project_name', 'moved_to_url'], list(page_data.keys()))
self.assertEqual(self.old_project, page_data['project_name'])
self.assertEqual('http://127.0.0.1/p/http-project/',
page_data['moved_to_url'])
@@ -106,8 +101,7 @@
path='/hosting/moved?project=%s' % self.old_project)
page_data = self.servlet.GatherPageData(mr)
- self.assertItemsEqual(
- ['project_name', 'moved_to_url'],
- list(page_data.keys()))
+ six.assertCountEqual(
+ self, ['project_name', 'moved_to_url'], list(page_data.keys()))
self.assertEqual(self.old_project, page_data['project_name'])
self.assertEqual('#invalid-destination-url', page_data['moved_to_url'])
diff --git a/sitewide/test/projectcreate_test.py b/sitewide/test/projectcreate_test.py
index 13dc97b..a79b9df 100644
--- a/sitewide/test/projectcreate_test.py
+++ b/sitewide/test/projectcreate_test.py
@@ -1,7 +1,6 @@
-# Copyright 2016 The Chromium Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style
-# license that can be found in the LICENSE file or at
-# https://developers.google.com/open-source/licenses/bsd
+# 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 the Project Creation servlet."""
from __future__ import print_function
@@ -12,8 +11,8 @@
import settings
from framework import permissions
-from proto import project_pb2
-from proto import site_pb2
+from mrproto import project_pb2
+from mrproto import site_pb2
from services import service_manager
from sitewide import projectcreate
from testing import fake
diff --git a/sitewide/test/projectsearch_test.py b/sitewide/test/projectsearch_test.py
index a0d941d..cd63e7f 100644
--- a/sitewide/test/projectsearch_test.py
+++ b/sitewide/test/projectsearch_test.py
@@ -1,7 +1,6 @@
-# Copyright 2016 The Chromium Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style
-# license that can be found in the LICENSE file or at
-# https://developers.google.com/open-source/licenses/bsd
+# 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 the projectsearch module."""
from __future__ import print_function
@@ -12,7 +11,7 @@
import unittest
from framework import profiler
-from proto import project_pb2
+from mrproto import project_pb2
from services import service_manager
from sitewide import projectsearch
from testing import fake
@@ -24,14 +23,14 @@
def setUp(self):
self.services = service_manager.Services(
project=fake.ProjectService())
- self.services.project.GetVisibleLiveProjects = mock.MagicMock()
+ self.services.project.GetVisibleProjects = mock.MagicMock()
for idx, letter in enumerate('abcdefghijklmnopqrstuvwxyz'):
self.services.project.TestAddProject(letter, project_id=idx + 1)
for idx in range(27, 110):
self.services.project.TestAddProject(str(idx), project_id=idx)
- self.addCleanup(mock.patch.stopall())
+ self.addCleanup(mock.patch.stopall)
def TestPipeline(self, expected_last, expected_len):
mr = testing_helpers.MakeMonorailRequest()
@@ -47,29 +46,28 @@
return pipeline
def testZeroResults(self):
- self.services.project.GetVisibleLiveProjects.return_value = []
+ self.services.project.GetVisibleProjects.return_value = []
pipeline = self.TestPipeline(0, 0)
- self.services.project.GetVisibleLiveProjects.assert_called_once()
+ self.services.project.GetVisibleProjects.assert_called_once()
self.assertListEqual([], pipeline.visible_results)
def testNonzeroResults(self):
- self.services.project.GetVisibleLiveProjects.return_value = [1, 2, 3]
+ self.services.project.GetVisibleProjects.return_value = [1, 2, 3]
pipeline = self.TestPipeline(3, 3)
- self.services.project.GetVisibleLiveProjects.assert_called_once()
+ self.services.project.GetVisibleProjects.assert_called_once()
self.assertListEqual(
[1, 2, 3], [p.project_id for p in pipeline.visible_results])
def testTwoPageResults(self):
"""Test more than one pagination page of results."""
- self.services.project.GetVisibleLiveProjects.return_value = list(
- range(1, 106))
+ self.services.project.GetVisibleProjects.return_value = list(range(1, 106))
pipeline = self.TestPipeline(100, 100)
- self.services.project.GetVisibleLiveProjects.assert_called_once()
+ self.services.project.GetVisibleProjects.assert_called_once()
self.assertEqual(
'/hosting/search?num=100&start=100', pipeline.pagination.next_url)
diff --git a/sitewide/test/sitewide_helpers_test.py b/sitewide/test/sitewide_helpers_test.py
index d292b6f..03905d9 100644
--- a/sitewide/test/sitewide_helpers_test.py
+++ b/sitewide/test/sitewide_helpers_test.py
@@ -1,16 +1,16 @@
-# Copyright 2016 The Chromium Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style
-# license that can be found in the LICENSE file or at
-# https://developers.google.com/open-source/licenses/bsd
+# 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.
"""Unit tests for the sitewide_helpers module."""
from __future__ import print_function
from __future__ import division
from __future__ import absolute_import
+import six
import unittest
-from proto import project_pb2
+from mrproto import project_pb2
from services import service_manager
from sitewide import sitewide_helpers
from testing import fake
@@ -93,7 +93,7 @@
# Check names rather than Project objects so that output is easier to read.
actual_names = [p.project_name for p in actual_projects]
expected_names = [p.project_name for p in expected_projects]
- self.assertItemsEqual(expected_names, actual_names)
+ six.assertCountEqual(self, expected_names, actual_names)
def testFilterViewableProjects_CantViewArchived(self):
projects = list(sitewide_helpers.FilterViewableProjects(
diff --git a/sitewide/test/sitewide_views_test.py b/sitewide/test/sitewide_views_test.py
index ed2515f..3622bdc 100644
--- a/sitewide/test/sitewide_views_test.py
+++ b/sitewide/test/sitewide_views_test.py
@@ -1,7 +1,6 @@
-# Copyright 2016 The Chromium Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style
-# license that can be found in the LICENSE file or at
-# https://developers.google.com/open-source/licenses/bsd
+# 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.
"""Unit tests for sitewide_views module."""
from __future__ import print_function
@@ -10,7 +9,7 @@
import unittest
-from proto import usergroup_pb2
+from mrproto import usergroup_pb2
from sitewide import sitewide_views
diff --git a/sitewide/test/userprofile_test.py b/sitewide/test/userprofile_test.py
index b4e29d8..42c901e 100644
--- a/sitewide/test/userprofile_test.py
+++ b/sitewide/test/userprofile_test.py
@@ -1,7 +1,6 @@
-# Copyright 2016 The Chromium Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style
-# license that can be found in the LICENSE file or at
-# https://developers.google.com/open-source/licenses/bsd
+# 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.
"""Tests for the user profile page."""
from __future__ import print_function
@@ -10,21 +9,18 @@
import mock
import unittest
-import logging
-import webapp2
import ezt
+import six
-from framework import framework_helpers
+from google.appengine.ext import testbed
+import pytest
+
from framework import framework_views
from framework import permissions
-from proto import project_pb2
-from proto import user_pb2
+from mrproto import project_pb2
from services import service_manager
from sitewide import userprofile
from testing import fake
-from testing import testing_helpers
-
-from google.appengine.ext import testbed
REGULAR_USER_ID = 111
ADMIN_USER_ID = 222
@@ -48,8 +44,7 @@
mr.viewed_user_auth.effective_ids = {viewed_user_id}
mr.viewed_user_auth.user_view = framework_views.UserView(viewed_user_pb)
mr.viewed_user_name = viewed_user_name
- mr.request = webapp2.Request.blank("/")
- mr.request_path = mr.request.path
+ mr.request_path = '/'
return mr
@@ -67,7 +62,7 @@
usergroup=fake.UserGroupService(),
project_star=fake.ProjectStarService(),
user_star=fake.UserStarService())
- self.servlet = userprofile.UserProfile('req', 'res', services=services)
+ self.servlet = userprofile.UserProfile(services=services)
for user_id in (
REGULAR_USER_ID, ADMIN_USER_ID, OTHER_USER_ID):
@@ -111,7 +106,7 @@
def assertProjectsAnyOrder(self, value_to_test, *expected_project_names):
actual_project_names = [project_view.project_name
for project_view in value_to_test]
- self.assertItemsEqual(expected_project_names, actual_project_names)
+ six.assertCountEqual(self, expected_project_names, actual_project_names)
def testGatherPageData_RegularUserViewingOtherUserProjects(self):
"""A user can see the other users' live projects, but not archived ones."""
@@ -125,13 +120,15 @@
'other-owner-live')
self.assertProjectsAnyOrder(page_data['committer_of_projects'],
'other-member-live')
- self.assertFalse(page_data['owner_of_archived_projects'])
+ self.assertProjectsAnyOrder(
+ page_data['owner_of_archived_projects'], 'other-owner-archived')
self.assertEqual('ot...@xyz.com', page_data['viewed_user_display_name'])
self.assertEqual(ezt.boolean(False), page_data['can_delete_user'])
self.mock_guspd.assert_called_once_with(
111, mr.viewed_user_auth.user_view, mr.viewed_user_auth.user_pb,
None)
+ @pytest.mark.skip(reason='Test is flaky (https://crbug.com/monorail/12052)')
def testGatherPageData_RegularUserViewingOwnProjects(self):
"""A user can see all their own projects: live or archived."""
mr = MakeReqInfo(
diff --git a/sitewide/test/usersettings_test.py b/sitewide/test/usersettings_test.py
index dd7d252..5675846 100644
--- a/sitewide/test/usersettings_test.py
+++ b/sitewide/test/usersettings_test.py
@@ -1,13 +1,13 @@
-# Copyright 2016 The Chromium Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style
-# license that can be found in the LICENSE file or at
-# https://developers.google.com/open-source/licenses/bsd
+# 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.
"""Tests for the user settings page."""
from __future__ import print_function
from __future__ import division
from __future__ import absolute_import
+import six
import unittest
try:
@@ -18,7 +18,7 @@
from framework import framework_helpers
from framework import permissions
from framework import template_helpers
-from proto import user_pb2
+from mrproto import user_pb2
from services import service_manager
from sitewide import usersettings
from testing import fake
@@ -58,10 +58,11 @@
mr = testing_helpers.MakeMonorailRequest()
page_data = self.servlet.GatherPageData(mr)
- self.assertItemsEqual(
- ['logged_in_user_pb', 'unified', 'user_tab_mode',
- 'viewed_user', 'offer_saved_queries_subtab', 'viewing_self'],
- list(page_data.keys()))
+ six.assertCountEqual(
+ self, [
+ 'logged_in_user_pb', 'unified', 'user_tab_mode', 'viewed_user',
+ 'offer_saved_queries_subtab', 'viewing_self'
+ ], list(page_data.keys()))
self.assertEqual(template_helpers.PBProxy(mr.auth.user_pb),
page_data['logged_in_user_pb'])
diff --git a/sitewide/test/userupdates_test.py b/sitewide/test/userupdates_test.py
index 725b123..d024755 100644
--- a/sitewide/test/userupdates_test.py
+++ b/sitewide/test/userupdates_test.py
@@ -1,7 +1,6 @@
-# Copyright 2016 The Chromium Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style
-# license that can be found in the LICENSE file or at
-# https://developers.google.com/open-source/licenses/bsd
+# 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.sitewide.userupdates."""
from __future__ import print_function
@@ -47,7 +46,7 @@
self.mox.ResetAll()
def testUserUpdatesProjects(self):
- uup = userupdates.UserUpdatesProjects(None, None, self.services)
+ uup = userupdates.UserUpdatesProjects(self.services)
self.mox.StubOutWithMock(sitewide_helpers, 'GetViewableStarredProjects')
sitewide_helpers.GetViewableStarredProjects(
@@ -73,7 +72,7 @@
self.assertEqual(uup._TAB_MODE, page_data['user_updates_tab_mode'])
def testUserUpdatesDevelopers(self):
- uud = userupdates.UserUpdatesDevelopers(None, None, self.services)
+ uud = userupdates.UserUpdatesDevelopers(self.services)
self.mox.StubOutWithMock(self.services.user_star, 'LookupStarredItemIDs')
self.services.user_star.LookupStarredItemIDs(
@@ -97,7 +96,7 @@
self.assertEqual(uud._TAB_MODE, page_data['user_updates_tab_mode'])
def testUserUpdatesIndividual(self):
- uui = userupdates.UserUpdatesIndividual(None, None, self.services)
+ uui = userupdates.UserUpdatesIndividual(self.services)
self.mox.StubOutWithMock(activities, 'GatherUpdatesData')
activities.GatherUpdatesData(