Add a test to verify push reports only set status
Also fix reporting on push along the way, as it turns out this wasn't
really working to begin with.
Within the fake github connection class, keep track of all the
reportings that have happened. These are just a simple list of tuples
about the reports, and we're only checking them in one test case for
now. This may be more useful down the road in other tests.
Change-Id: I85bb7a580c21f0762187f2176b74983baf6e8509
diff --git a/tests/base.py b/tests/base.py
index d89469f..5e084fe 100755
--- a/tests/base.py
+++ b/tests/base.py
@@ -868,6 +868,7 @@
self.upstream_root = upstream_root
self.merge_failure = False
self.merge_not_allowed_count = 0
+ self.reports = []
def openFakePullRequest(self, project, branch, subject, files=[]):
self.pr_number += 1
@@ -979,10 +980,14 @@
return ['master']
def commentPull(self, project, pr_number, message):
+ # record that this got reported
+ self.reports.append((project, pr_number, 'comment'))
pull_request = self.pull_requests[pr_number - 1]
pull_request.addComment(message)
def mergePull(self, project, pr_number, commit_message='', sha=None):
+ # record that this got reported
+ self.reports.append((project, pr_number, 'merge'))
pull_request = self.pull_requests[pr_number - 1]
if self.merge_failure:
raise Exception('Pull request was not merged')
@@ -998,6 +1003,8 @@
def setCommitStatus(self, project, sha, state, url='', description='',
context='default', user='zuul'):
+ # record that this got reported
+ self.reports.append((project, sha, 'status', (user, context, state)))
# always insert a status to the front of the list, to represent
# the last status provided for a commit.
# Since we're bypassing github API, which would require a user, we
@@ -1014,10 +1021,14 @@
})
def labelPull(self, project, pr_number, label):
+ # record that this got reported
+ self.reports.append((project, pr_number, 'label', label))
pull_request = self.pull_requests[pr_number - 1]
pull_request.addLabel(label)
def unlabelPull(self, project, pr_number, label):
+ # record that this got reported
+ self.reports.append((project, pr_number, 'unlabel', label))
pull_request = self.pull_requests[pr_number - 1]
pull_request.removeLabel(label)