-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Alice Ferrazzi <[email protected]>
- Loading branch information
1 parent
6ddad8b
commit 2cbf0c3
Showing
1 changed file
with
97 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,6 +19,7 @@ | |
from buildbot.process.properties import Interpolate | ||
from buildbot.process.results import FAILURE | ||
from buildbot.process.results import SUCCESS | ||
from buildbot.reporters.github import HOSTED_BASE_REGEX | ||
from buildbot.reporters.github import HOSTED_BASE_URL | ||
from buildbot.reporters.github import GitHubCommentPush | ||
from buildbot.reporters.github import GitHubStatusPush | ||
|
@@ -431,3 +432,99 @@ def test_multiple_source_stamps_no_props(self): | |
yield self.sp._got_event(('builds', 20, 'finished'), build) | ||
build['results'] = SUCCESS | ||
yield self.sp._got_event(('builds', 20, 'finished'), build) | ||
|
||
|
||
# Testing HOSTED_BASE_REGEX | ||
class TestGitHubRegEX(TestReactorMixin, unittest.TestCase, | ||
ReporterTestMixin): | ||
|
||
@defer.inlineCallbacks | ||
def setUp(self): | ||
self.setup_test_reactor() | ||
|
||
self.setup_reporter_test() | ||
# project must be in the form <owner>/<project> | ||
self.reporter_test_project = 'buildbot' | ||
self.reporter_test_repo = 'https://github.com/buildbot1/buildbot1.git' | ||
|
||
self.master = fakemaster.make_master(self, wantData=True, wantDb=True, | ||
wantMq=True) | ||
|
||
yield self.master.startService() | ||
self._http = yield fakehttpclientservice.HTTPClientService.getService( | ||
self.master, self, | ||
HOSTED_BASE_URL, headers={ | ||
'Authorization': 'token XXYYZZ', | ||
'User-Agent': 'Buildbot' | ||
}, | ||
debug=None, verify=None) | ||
self.sp = self.createService() | ||
yield self.sp.setServiceParent(self.master) | ||
|
||
def createService(self): | ||
return GitHubStatusPush('XXYYZZ', base_re=HOSTED_BASE_REGEX) | ||
|
||
def tearDown(self): | ||
return self.master.stopService() | ||
|
||
@defer.inlineCallbacks | ||
def test_ssh(self): | ||
self.reporter_test_repo = '[email protected]:buildbot2/buildbot2.git' | ||
|
||
build = yield self.insert_build_new() | ||
# we make sure proper calls to txrequests have been made | ||
self._http.expect( | ||
'post', | ||
'/repos/buildbot2/buildbot2/statuses/d34db33fd43db33f', | ||
json={'state': 'pending', | ||
'target_url': 'http://localhost:8080/#builders/79/builds/0', | ||
'description': 'Build started.', 'context': 'buildbot/Builder0'}) | ||
self._http.expect( | ||
'post', | ||
'/repos/buildbot2/buildbot2/statuses/d34db33fd43db33f', | ||
json={'state': 'success', | ||
'target_url': 'http://localhost:8080/#builders/79/builds/0', | ||
'description': 'Build done.', 'context': 'buildbot/Builder0'}) | ||
self._http.expect( | ||
'post', | ||
'/repos/buildbot2/buildbot2/statuses/d34db33fd43db33f', | ||
json={'state': 'failure', | ||
'target_url': 'http://localhost:8080/#builders/79/builds/0', | ||
'description': 'Build done.', 'context': 'buildbot/Builder0'}) | ||
|
||
yield self.sp._got_event(('builds', 20, 'new'), build) | ||
build['complete'] = True | ||
build['results'] = SUCCESS | ||
yield self.sp._got_event(('builds', 20, 'finished'), build) | ||
build['results'] = FAILURE | ||
yield self.sp._got_event(('builds', 20, 'finished'), build) | ||
|
||
@defer.inlineCallbacks | ||
def test_https(self): | ||
build = yield self.insert_build_new() | ||
# we make sure proper calls to txrequests have been made | ||
self._http.expect( | ||
'post', | ||
'/repos/buildbot1/buildbot1/statuses/d34db33fd43db33f', | ||
json={'state': 'pending', | ||
'target_url': 'http://localhost:8080/#builders/79/builds/0', | ||
'description': 'Build started.', 'context': 'buildbot/Builder0'}) | ||
self._http.expect( | ||
'post', | ||
'/repos/buildbot1/buildbot1/statuses/d34db33fd43db33f', | ||
json={'state': 'success', | ||
'target_url': 'http://localhost:8080/#builders/79/builds/0', | ||
'description': 'Build done.', 'context': 'buildbot/Builder0'}) | ||
self._http.expect( | ||
'post', | ||
'/repos/buildbot1/buildbot1/statuses/d34db33fd43db33f', | ||
json={'state': 'failure', | ||
'target_url': 'http://localhost:8080/#builders/79/builds/0', | ||
'description': 'Build done.', 'context': 'buildbot/Builder0'}) | ||
|
||
yield self.sp._got_event(('builds', 20, 'new'), build) | ||
build['complete'] = True | ||
build['results'] = SUCCESS | ||
yield self.sp._got_event(('builds', 20, 'finished'), build) | ||
build['results'] = FAILURE | ||
yield self.sp._got_event(('builds', 20, 'finished'), build) |