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

Unified Diff: tests/presubmit_unittest.py

Issue 1090943003: Skip OWNERS checks for CQ dry runs (Closed) Base URL: https://chromium.googlesource.com/chromium/tools/depot_tools.git@master
Patch Set: Cleanup Created 5 years, 8 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_canned_checks.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 ebafb67b1bdb9e2c34ff6b88337845300fdc311f..0d2b4d68f833e8452495d70019820b91f4797685 100755
--- a/tests/presubmit_unittest.py
+++ b/tests/presubmit_unittest.py
@@ -2570,7 +2570,7 @@ class CannedChecksUnittest(PresubmitTestsBase):
def AssertOwnersWorks(self, tbr=False, issue='1', approvers=None,
reviewers=None, is_committing=True, rietveld_response=None,
uncovered_files=None, expected_output='',
- manually_specified_reviewers=None):
+ manually_specified_reviewers=None, cq_dry_run=False):
if approvers is None:
# The set of people who lgtm'ed a change.
approvers = set()
@@ -2598,8 +2598,9 @@ class CannedChecksUnittest(PresubmitTestsBase):
input_api.tbr = tbr
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 cq_dry_run:
+ affected_file.LocalPath().AndReturn('foo/xyz.cc')
+ change.AffectedFiles(file_filter=None).AndReturn([affected_file])
if issue and not rietveld_response:
rietveld_response = {
"owner_email": change.author_email,
@@ -2612,20 +2613,25 @@ class CannedChecksUnittest(PresubmitTestsBase):
if is_committing:
people = approvers
+ if issue:
+ input_api.rietveld.get_issue_properties(
+ issue=int(input_api.change.issue), messages=None).AndReturn(
+ rietveld_response)
else:
people = reviewers
- if issue:
- input_api.rietveld.get_issue_properties(
- issue=int(input_api.change.issue), messages=True).AndReturn(
- rietveld_response)
+ if not cq_dry_run:
+ if issue:
+ input_api.rietveld.get_issue_properties(
+ issue=int(input_api.change.issue), messages=True).AndReturn(
+ rietveld_response)
- people.add(change.author_email)
- fake_db.files_not_covered_by(set(['foo/xyz.cc']),
- people).AndReturn(uncovered_files)
- if not is_committing and uncovered_files:
- fake_db.reviewers_for(set(['foo']),
- change.author_email).AndReturn(change.author_email)
+ people.add(change.author_email)
+ fake_db.files_not_covered_by(set(['foo/xyz.cc']),
+ people).AndReturn(uncovered_files)
+ if not is_committing and uncovered_files:
+ fake_db.reviewers_for(set(['foo']),
+ change.author_email).AndReturn(change.author_email)
self.mox.ReplayAll()
output = presubmit.PresubmitOutput()
@@ -2635,6 +2641,23 @@ class CannedChecksUnittest(PresubmitTestsBase):
results[0].handle(output)
self.assertEquals(output.getvalue(), expected_output)
+ def testCannedCheckOwners_DryRun(self):
+ response = {
+ "owner_email": "john@example.com",
+ "cq_dry_run": True,
+ "reviewers": ["ben@example.com"],
+ }
+ self.AssertOwnersWorks(approvers=set(),
+ cq_dry_run=True,
+ rietveld_response=response,
+ reviewers=set(["ben@example.com"]),
+ expected_output='This is a CQ dry run, skipping OWNERS check\n')
+
+ self.AssertOwnersWorks(approvers=set(['ben@example.com']),
+ is_committing=False,
+ rietveld_response=response,
+ expected_output='')
+
def testCannedCheckOwners_Approved(self):
response = {
"owner_email": "john@example.com",
« no previous file with comments | « presubmit_canned_checks.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698