Merge branch 'main' into avm99963-monorail
Merged commit 34d8229ae2b51fb1a15bd208e6fe6185c94f6266
GitOrigin-RevId: 7ee0917f93a577e475f8e09526dd144d245593f4
diff --git a/services/test/project_svc_test.py b/services/test/project_svc_test.py
index 48de180..3ada8ea 100644
--- a/services/test/project_svc_test.py
+++ b/services/test/project_svc_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 project_svc module."""
from __future__ import print_function
from __future__ import division
from __future__ import absolute_import
+import six
import time
import unittest
@@ -21,8 +21,8 @@
from framework import framework_constants
from framework import sql
-from proto import project_pb2
-from proto import user_pb2
+from mrproto import project_pb2
+from mrproto import user_pb2
from services import config_svc
from services import project_svc
from testing import fake
@@ -79,15 +79,15 @@
project_dict = self.project_service.project_2lc._DeserializeProjects(
project_rows, role_rows, extraperm_rows)
- self.assertItemsEqual([123, 234], list(project_dict.keys()))
+ six.assertCountEqual(self, [123, 234], list(project_dict.keys()))
self.assertEqual(123, project_dict[123].project_id)
self.assertEqual('proj1', project_dict[123].project_name)
self.assertEqual(NOW, project_dict[123].recent_activity)
- self.assertItemsEqual([111, 444], project_dict[123].owner_ids)
- self.assertItemsEqual([222], project_dict[123].committer_ids)
- self.assertItemsEqual([333], project_dict[123].contributor_ids)
+ six.assertCountEqual(self, [111, 444], project_dict[123].owner_ids)
+ six.assertCountEqual(self, [222], project_dict[123].committer_ids)
+ six.assertCountEqual(self, [333], project_dict[123].contributor_ids)
self.assertEqual(234, project_dict[234].project_id)
- self.assertItemsEqual([111], project_dict[234].owner_ids)
+ six.assertCountEqual(self, [111], project_dict[234].owner_ids)
self.assertEqual(False, project_dict[123].issue_notify_always_detailed)
self.assertEqual(True, project_dict[234].issue_notify_always_detailed)
@@ -278,7 +278,7 @@
project_dict = self.project_service.GetProjects(
self.cnxn, [123, 234])
self.mox.VerifyAll()
- self.assertItemsEqual([123, 234], list(project_dict.keys()))
+ six.assertCountEqual(self, [123, 234], list(project_dict.keys()))
self.assertEqual('proj1', project_dict[123].project_name)
self.assertEqual('proj2', project_dict[234].project_name)
@@ -288,7 +288,7 @@
self.mox.ReplayAll()
project_dict = self.project_service.GetProjects(self.cnxn, [234])
self.mox.VerifyAll()
- self.assertItemsEqual([234], list(project_dict.keys()))
+ six.assertCountEqual(self, [234], list(project_dict.keys()))
self.assertEqual(
[project_pb2.Project.ExtraPerms(
member_id=111, perms=['FooPerm']),
@@ -297,7 +297,7 @@
project_dict[234].extra_perms)
- def testGetVisibleLiveProjects_AnyoneAccessWithUser(self):
+ def testGetVisibleProjects_AnyoneAccessWithUser(self):
project_rows = [
(
234, 'proj2', 'test proj 2', 'test project', 'live', 'anyone', '',
@@ -311,13 +311,13 @@
self.SetUpGetProjects()
self.mox.ReplayAll()
user_a = user_pb2.User(email='a@example.com')
- project_ids = self.project_service.GetVisibleLiveProjects(
+ project_ids = self.project_service.GetVisibleProjects(
self.cnxn, user_a, set([111]))
self.mox.VerifyAll()
- self.assertItemsEqual([234], project_ids)
+ six.assertCountEqual(self, [234], project_ids)
- def testGetVisibleLiveProjects_AnyoneAccessWithAnon(self):
+ def testGetVisibleProjects_AnyoneAccessWithAnon(self):
project_rows = [
(
234, 'proj2', 'test proj 2', 'test project', 'live', 'anyone', '',
@@ -330,13 +330,12 @@
state=project_pb2.ProjectState.LIVE).AndReturn(project_rows)
self.SetUpGetProjects()
self.mox.ReplayAll()
- project_ids = self.project_service.GetVisibleLiveProjects(
- self.cnxn, None, None)
+ project_ids = self.project_service.GetVisibleProjects(self.cnxn, None, None)
self.mox.VerifyAll()
- self.assertItemsEqual([234], project_ids)
+ six.assertCountEqual(self, [234], project_ids)
- def testGetVisibleLiveProjects_RestrictedAccessWithMember(self):
+ def testGetVisibleProjects_RestrictedAccessWithMember(self):
project_rows = [
(
234, 'proj2', 'test proj 2', 'test project', 'live', 'members_only',
@@ -352,13 +351,13 @@
state=project_pb2.ProjectState.LIVE).AndReturn(project_rows)
self.mox.ReplayAll()
user_a = user_pb2.User(email='a@example.com')
- project_ids = self.project_service.GetVisibleLiveProjects(
+ project_ids = self.project_service.GetVisibleProjects(
self.cnxn, user_a, set([111]))
self.mox.VerifyAll()
- self.assertItemsEqual([234], project_ids)
+ six.assertCountEqual(self, [234], project_ids)
- def testGetVisibleLiveProjects_RestrictedAccessWithNonMember(self):
+ def testGetVisibleProjects_RestrictedAccessWithNonMember(self):
project_rows = [
(
234, 'proj2', 'test proj 2', 'test project', 'live', 'members_only',
@@ -373,13 +372,13 @@
state=project_pb2.ProjectState.LIVE).AndReturn(project_rows)
self.mox.ReplayAll()
user_a = user_pb2.User(email='a@example.com')
- project_ids = self.project_service.GetVisibleLiveProjects(
+ project_ids = self.project_service.GetVisibleProjects(
self.cnxn, user_a, set([111]))
self.mox.VerifyAll()
- self.assertItemsEqual([], project_ids)
+ six.assertCountEqual(self, [], project_ids)
- def testGetVisibleLiveProjects_RestrictedAccessWithAnon(self):
+ def testGetVisibleProjects_RestrictedAccessWithAnon(self):
project_rows = [
(
234, 'proj2', 'test proj 2', 'test project', 'live', 'members_only',
@@ -393,13 +392,12 @@
self.cnxn, cols=['project_id'],
state=project_pb2.ProjectState.LIVE).AndReturn(project_rows)
self.mox.ReplayAll()
- project_ids = self.project_service.GetVisibleLiveProjects(
- self.cnxn, None, None)
+ project_ids = self.project_service.GetVisibleProjects(self.cnxn, None, None)
self.mox.VerifyAll()
- self.assertItemsEqual([], project_ids)
+ six.assertCountEqual(self, [], project_ids)
- def testGetVisibleLiveProjects_RestrictedAccessWithSiteAdmin(self):
+ def testGetVisibleProjects_RestrictedAccessWithSiteAdmin(self):
project_rows = [
(
234, 'proj2', 'test proj 2', 'test project', 'live', 'members_only',
@@ -415,13 +413,13 @@
self.mox.ReplayAll()
user_a = user_pb2.User(email='a@example.com')
user_a.is_site_admin = True
- project_ids = self.project_service.GetVisibleLiveProjects(
+ project_ids = self.project_service.GetVisibleProjects(
self.cnxn, user_a, set([111]))
self.mox.VerifyAll()
- self.assertItemsEqual([234], project_ids)
+ six.assertCountEqual(self, [234], project_ids)
- def testGetVisibleLiveProjects_ArchivedProject(self):
+ def testGetVisibleProjects_ArchivedProject(self):
project_rows = [
(
234, 'proj2', 'test proj 2', 'test project', 'archived', 'anyone',
@@ -436,11 +434,11 @@
state=project_pb2.ProjectState.LIVE).AndReturn(project_rows)
self.mox.ReplayAll()
user_a = user_pb2.User(email='a@example.com')
- project_ids = self.project_service.GetVisibleLiveProjects(
+ project_ids = self.project_service.GetVisibleProjects(
self.cnxn, user_a, set([111]))
self.mox.VerifyAll()
- self.assertItemsEqual([], project_ids)
+ six.assertCountEqual(self, [234], project_ids)
def testGetProjectsByName(self):
self.project_service.project_names_to_ids.CacheItem('proj1', 123)
@@ -451,7 +449,7 @@
project_dict = self.project_service.GetProjectsByName(
self.cnxn, ['proj1', 'proj2'])
self.mox.VerifyAll()
- self.assertItemsEqual(['proj1', 'proj2'], list(project_dict.keys()))
+ six.assertCountEqual(self, ['proj1', 'proj2'], list(project_dict.keys()))
self.assertEqual(123, project_dict['proj1'].project_id)
self.assertEqual(234, project_dict['proj2'].project_id)
@@ -584,18 +582,18 @@
self.cnxn, {111, 888})
owned_project_ids, membered_project_ids, contrib_project_ids = actual
self.mox.VerifyAll()
- self.assertItemsEqual([234], owned_project_ids)
- self.assertItemsEqual([123], membered_project_ids)
- self.assertItemsEqual([], contrib_project_ids)
+ six.assertCountEqual(self, [234], owned_project_ids)
+ six.assertCountEqual(self, [123], membered_project_ids)
+ six.assertCountEqual(self, [], contrib_project_ids)
def testGetUserRolesInAllProjectsWithoutEffectiveIds(self):
self.mox.ReplayAll()
actual = self.project_service.GetUserRolesInAllProjects(self.cnxn, {})
owned_project_ids, membered_project_ids, contrib_project_ids = actual
self.mox.VerifyAll()
- self.assertItemsEqual([], owned_project_ids)
- self.assertItemsEqual([], membered_project_ids)
- self.assertItemsEqual([], contrib_project_ids)
+ six.assertCountEqual(self, [], owned_project_ids)
+ six.assertCountEqual(self, [], membered_project_ids)
+ six.assertCountEqual(self, [], contrib_project_ids)
def SetUpUpdateExtraPerms(self):
self.project_service.extraperm_tbl.Delete(