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

Unified Diff: tests/presubmit_unittest.py

Issue 2178673002: Have presubmit accept various Code-Review label configurations (Closed) Base URL: https://chromium.googlesource.com/chromium/tools/depot_tools.git@master
Patch Set: Tests and comments Created 4 years, 5 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 2863c1446cebbd076238c826e8a12e11dd2d8b20..1f65eb97cf6d1f4915534c648f94e808742da8ce 100755
--- a/tests/presubmit_unittest.py
+++ b/tests/presubmit_unittest.py
@@ -2725,6 +2725,29 @@ class CannedChecksUnittest(PresubmitTestsBase):
gerrit_response=response,
expected_output='')
+ # Testing configuration with on -1..+1.
+ response = {
+ "owner": {"email": "john@example.com"},
+ "labels": {"Code-Review": {
+ u'all': [
+ {
+ u'email': u'ben@example.com',
+ u'value': 1
+ },
+ ],
+ u'approved': {u'email': u'ben@example.org'},
+ u'default_value': 0,
+ u'values': {u' 0': u'No score',
+ u'+1': u'Looks good to me',
+ u'-1': u"I would prefer that you didn't submit this"}
+ }},
+ }
+ self.AssertOwnersWorks(approvers=set(['ben@example.com']),
+ gerrit_response=response,
+ is_committing=True,
+ expected_output='')
+
+
def testCannedCheckOwners_Approved(self):
response = {
"owner_email": "john@example.com",
@@ -2744,6 +2767,69 @@ class CannedChecksUnittest(PresubmitTestsBase):
rietveld_response=response,
expected_output='')
+ def testCannedCheckOwners_NotApproved_Gerrit(self):
+ response = {
+ "owner": {"email": "john@example.com"},
+ "labels": {"Code-Review": {
+ u'all': [
+ {
+ u'email': u'john@example.com', # self +1 :)
+ u'value': 1
+ },
+ {
+ u'email': u'ben@example.com',
+ u'value': 1
+ },
+ ],
+ u'approved': {u'email': u'ben@example.org'},
+ u'default_value': 0,
+ u'values': {u' 0': u'No score',
+ u'+1': u'Looks good to me, but someone else must approve',
+ u'+2': u'Looks good to me, approved',
+ u'-1': u"I would prefer that you didn't submit this",
+ u'-2': u'Do not submit'}
+ }},
+ }
+ self.AssertOwnersWorks(
+ approvers=set(),
+ reviewers=set(["ben@example.com"]),
+ gerrit_response=response,
+ is_committing=True,
+ expected_output=
+ 'Missing LGTM from someone other than john@example.com\n')
+
+ self.AssertOwnersWorks(
+ approvers=set(),
+ reviewers=set(["ben@example.com"]),
+ is_committing=False,
+ gerrit_response=response,
+ expected_output='')
+
+ # Testing configuration with on -1..+1.
+ response = {
+ "owner": {"email": "john@example.com"},
+ "labels": {"Code-Review": {
+ u'all': [
+ {
+ u'email': u'ben@example.com',
+ u'value': 0
+ },
+ ],
+ u'approved': {u'email': u'ben@example.org'},
+ u'default_value': 0,
+ u'values': {u' 0': u'No score',
+ u'+1': u'Looks good to me',
+ u'-1': u"I would prefer that you didn't submit this"}
+ }},
+ }
+ self.AssertOwnersWorks(
+ approvers=set(),
+ reviewers=set(["ben@example.com"]),
+ gerrit_response=response,
+ is_committing=True,
+ expected_output=
+ 'Missing LGTM from someone other than john@example.com\n')
+
def testCannedCheckOwners_NotApproved(self):
response = {
"owner_email": "john@example.com",
« 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