Merge branch 'main' into avm99963-monorail
Merged commit 34d8229ae2b51fb1a15bd208e6fe6185c94f6266
GitOrigin-RevId: 7ee0917f93a577e475f8e09526dd144d245593f4
diff --git a/api/test/resource_name_converters_test.py b/api/test/resource_name_converters_test.py
index e9ca437..eed6957 100644
--- a/api/test/resource_name_converters_test.py
+++ b/api/test/resource_name_converters_test.py
@@ -1,7 +1,6 @@
-# Copyright 2018 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 2018 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 converting between resource names and external ids."""
from __future__ import print_function
@@ -16,7 +15,7 @@
from framework import exceptions
from testing import fake
from services import service_manager
-from proto import tracker_pb2
+from mrproto import tracker_pb2
class ResourceNameConverterTest(unittest.TestCase):
@@ -173,9 +172,9 @@
'hotlists/78909/items/proj.1', 'hotlists/78909/items/chicken.2',
'hotlists/78909/items/cow.3'
]
- with self.assertRaisesRegexp(exceptions.NoSuchProjectException,
- 'Project chicken not found.\n' +
- 'Project cow not found.'):
+ with self.assertRaisesRegex(exceptions.NoSuchProjectException,
+ 'Project chicken not found.\n' +
+ 'Project cow not found.'):
rnc.IngestHotlistItemNames(self.cnxn, names, self.services)
def testIngestHotlistItems_IssueNotFound(self):
@@ -183,7 +182,7 @@
names = [
'hotlists/78909/items/proj.1',
'hotlists/78909/items/goose.5']
- with self.assertRaisesRegexp(exceptions.NoSuchIssueException, '%r' % names):
+ with self.assertRaisesRegex(exceptions.NoSuchIssueException, '%r' % names):
rnc.IngestHotlistItemNames(self.cnxn, names, self.services)
def testConvertHotlistName(self):
@@ -193,8 +192,10 @@
def testConvertHotlistItemNames(self):
"""We can get Hotlist items' resource names."""
expected_dict = {
- self.hotlist_1.items[0].issue_id: 'hotlists/7739/items/proj.1',
- self.hotlist_1.items[1].issue_id: 'hotlists/7739/items/goose.2',
+ self.hotlist_1.items[0].issue_id:
+ 'hotlists/%d/items/proj.1' % self.hotlist_1.hotlist_id,
+ self.hotlist_1.items[1].issue_id:
+ 'hotlists/%d/items/goose.2' % self.hotlist_1.hotlist_id,
}
self.assertEqual(
rnc.ConvertHotlistItemNames(
@@ -214,8 +215,8 @@
self.cnxn, 'projects/noproj/issues/1/approvalValues/1', self.services)
def testIngestApprovalValueName_IssueDoesNotExist(self):
- with self.assertRaisesRegexp(exceptions.NoSuchIssueException,
- 'projects/proj/issues/404'):
+ with self.assertRaisesRegex(exceptions.NoSuchIssueException,
+ 'projects/proj/issues/404'):
rnc.IngestApprovalValueName(
self.cnxn, 'projects/proj/issues/404/approvalValues/1', self.services)
@@ -292,7 +293,7 @@
def testIngestIssueNames_WithBadInputs(self):
"""We aggregate input exceptions."""
- with self.assertRaisesRegexp(
+ with self.assertRaisesRegex(
exceptions.InputException,
'Invalid resource name: projects/proj/badformat/1.\n' +
'Invalid resource name: badformat/proj/issues/1.'):
@@ -312,15 +313,15 @@
def testIngestIssueNames_ManyDoNotExist(self):
"""We get an exception if one issue name provided does not exist."""
dne_issues = ['projects/proj/issues/2', 'projects/proj/issues/3']
- with self.assertRaisesRegexp(exceptions.NoSuchIssueException,
- '%r' % dne_issues):
+ with self.assertRaisesRegex(exceptions.NoSuchIssueException,
+ '%r' % dne_issues):
rnc.IngestIssueNames(self.cnxn, dne_issues, self.services)
def testIngestIssueNames_ProjectsNotExist(self):
"""Aggregated exceptions raised if projects are not found."""
- with self.assertRaisesRegexp(exceptions.NoSuchProjectException,
- 'Project chicken not found.\n' +
- 'Project cow not found.'):
+ with self.assertRaisesRegex(exceptions.NoSuchProjectException,
+ 'Project chicken not found.\n' +
+ 'Project cow not found.'):
rnc.IngestIssueNames(
self.cnxn, [
'projects/chicken/issues/2', 'projects/cow/issues/3',
@@ -354,8 +355,8 @@
self.cnxn, 'projects/doesnotexist/issues/1/comments/0', self.services)
def testIngestCommentName_NoSuchIssue(self):
- with self.assertRaisesRegexp(exceptions.NoSuchIssueException,
- "['projects/proj/issues/404']"):
+ with self.assertRaisesRegex(exceptions.NoSuchIssueException,
+ "['projects/proj/issues/404']"):
rnc.IngestCommentName(
self.cnxn, 'projects/proj/issues/404/comments/0', self.services)
@@ -641,8 +642,8 @@
names = ['projects/xyz/componentDefs/1', 'projects/zyz/componentDefs/1']
expected_error = 'Project not found: xyz.\nProject not found: zyz.'
- with self.assertRaisesRegexp(exceptions.NoSuchProjectException,
- expected_error):
+ with self.assertRaisesRegex(exceptions.NoSuchProjectException,
+ expected_error):
rnc.IngestComponentDefNames(self.cnxn, names, self.services)
def testIngestComponentDefNames_NoSuchComponentException(self):
@@ -654,8 +655,8 @@
'projects/proj/componentDefs/999', 'projects/proj/componentDefs/cow'
]
expected_error = 'Component not found: 999.\nComponent not found: \'cow\'.'
- with self.assertRaisesRegexp(exceptions.NoSuchComponentException,
- expected_error):
+ with self.assertRaisesRegex(exceptions.NoSuchComponentException,
+ expected_error):
rnc.IngestComponentDefNames(self.cnxn, names, self.services)
def testIngestComponentDefNames_InvalidNames(self):