Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1196)

Unified Diff: tests/presubmit_unittest.py

Issue 195793021: Infer CL author and reviewer list from local state if the issue has not previously been uploaded. (Closed) Base URL: https://chromium.googlesource.com/chromium/tools/depot_tools.git@master
Patch Set: Add an additional test Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « presubmit_support.py ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/presubmit_unittest.py
diff --git a/tests/presubmit_unittest.py b/tests/presubmit_unittest.py
index 6c2c8b3a6022085ab50a3f3bb2d44b20f8ed1f8e..4658a698a324a8c260b6142e846435ab2bebf499 100755
--- a/tests/presubmit_unittest.py
+++ b/tests/presubmit_unittest.py
@@ -1768,7 +1768,7 @@ class ChangeUnittest(PresubmitTestsBase):
'AbsoluteLocalPaths', 'AffectedFiles', 'AffectedTextFiles',
'DescriptionText', 'FullDescriptionText', 'LocalPaths', 'Name',
'RepositoryRoot', 'RightHandSideLines', 'ServerPaths',
- 'TAG_LINE_RE',
+ 'SetDescriptionText', 'TAG_LINE_RE',
'author_email', 'issue', 'patchset', 'scm', 'tags',
]
# If this test fails, you should add the relevant test.
@@ -1791,6 +1791,19 @@ class ChangeUnittest(PresubmitTestsBase):
self.assertEquals(1, len(change.AffectedFiles(include_dirs=True)))
self.assertEquals('Y', change.AffectedFiles(include_dirs=True)[0].Action())
+ def testSetDescriptionText(self):
+ change = presubmit.Change(
+ '', 'foo\nDRU=ro', self.fake_root_dir, [], 3, 5, '')
+ self.assertEquals('foo', change.DescriptionText())
+ self.assertEquals('foo\nDRU=ro', change.FullDescriptionText())
+ self.assertEquals('ro', change.DRU)
+
+ change.SetDescriptionText('bar\nWHIZ=bang')
+ self.assertEquals('bar', change.DescriptionText())
+ self.assertEquals('bar\nWHIZ=bang', change.FullDescriptionText())
+ self.assertEquals('bang', change.WHIZ)
+ self.assertFalse(change.DRU)
+
def CommHelper(input_api, cmd, ret=None, **kwargs):
ret = ret or (('', None), 0)
@@ -2574,6 +2587,8 @@ class CannedChecksUnittest(PresubmitTestsBase):
change = self.mox.CreateMock(presubmit.Change)
change.issue = issue
change.author_email = 'john@example.com'
+ change.R = ''
+ change.TBR = ''
affected_file = self.mox.CreateMock(presubmit.SvnAffectedFile)
input_api = self.MockInputApi(change, False)
fake_db = self.mox.CreateMock(owners.Database)
@@ -2585,7 +2600,7 @@ class CannedChecksUnittest(PresubmitTestsBase):
if not is_committing or (not tbr and issue):
affected_file.LocalPath().AndReturn('foo/xyz.cc')
change.AffectedFiles(file_filter=None).AndReturn([affected_file])
- if not rietveld_response:
+ if issue and not rietveld_response:
rietveld_response = {
"owner_email": change.author_email,
"messages": [
@@ -2599,6 +2614,7 @@ class CannedChecksUnittest(PresubmitTestsBase):
people = approvers
else:
people = reviewers
+ change.R = ','.join(reviewers)
if issue:
input_api.rietveld.get_issue_properties(
@@ -2710,6 +2726,16 @@ class CannedChecksUnittest(PresubmitTestsBase):
expected_output='Missing OWNER reviewers for these files:\n'
' foo\n')
+ def testCannedCheckOwners_NoIssueLocalReviewers(self):
+ self.AssertOwnersWorks(issue=None,
+ reviewers=set(['jane@example.com']),
+ expected_output="OWNERS check failed: this change has no Rietveld "
+ "issue number, so we can't check it for approvals.\n")
+ self.AssertOwnersWorks(issue=None,
+ reviewers=set(['jane@example.com']),
+ is_committing=False,
+ expected_output='')
+
def testCannedCheckOwners_NoLGTM(self):
self.AssertOwnersWorks(expected_output='Missing LGTM from someone '
'other than john@example.com\n')
« no previous file with comments | « presubmit_support.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698