Skip to content

Commit

Permalink
isort+autopep8 run
Browse files Browse the repository at this point in the history
  • Loading branch information
tardyp committed Jul 26, 2016
1 parent bdb02c0 commit e439b49
Show file tree
Hide file tree
Showing 5 changed files with 64 additions and 46 deletions.
2 changes: 1 addition & 1 deletion Makefile
Expand Up @@ -51,7 +51,7 @@ rmpyc:
find . \( -name '*.pyc' -o -name '*.pyo' \) -exec rm -v {} \;

isort:
isort -rc .
isort -rc worker master
git diff --name-only --stat "HEAD" | grep '.py$$' | xargs autopep8 -i
git commit -a -m "isort+autopep8 run"

Expand Down
59 changes: 34 additions & 25 deletions master/buildbot/test/unit/test_reporter_bitbucket.py
Expand Up @@ -14,7 +14,6 @@
# Copyright Buildbot Team Members
from mock import Mock
from mock import call

from twisted.internet import defer
from twisted.trial import unittest

Expand Down Expand Up @@ -72,44 +71,54 @@ def test_basic(self):
call('https://bitbucket.org/site/oauth2/access_token',
auth=('key', 'secret'),
data={'grant_type': 'client_credentials'}),
call(u'https://api.bitbucket.org/2.0/repositories/user/repo/commit/d34db33fd43db33f/statuses/build',
json={
'url': 'http://localhost:8080/#builders/79/builds/0',
'state': 'INPROGRESS',
'key': u'Builder0',
'name': u'Builder0'}),
call(
u'https://api.bitbucket.org/2.0/repositories/user/repo/commit/d34db33fd43db33f/statuses/build',
json={
'url': 'http://localhost:8080/#builders/79/builds/0',
'state': 'INPROGRESS',
'key': u'Builder0',
'name': u'Builder0'}),
call('https://bitbucket.org/site/oauth2/access_token',
auth=('key', 'secret'),
data={'grant_type': 'client_credentials'}),
call(u'https://api.bitbucket.org/2.0/repositories/user/repo/commit/d34db33fd43db33f/statuses/build',
json={
'url': 'http://localhost:8080/#builders/79/builds/0',
'state': 'SUCCESSFUL',
'key': u'Builder0',
'name': u'Builder0'}),
call(
u'https://api.bitbucket.org/2.0/repositories/user/repo/commit/d34db33fd43db33f/statuses/build',
json={
'url': 'http://localhost:8080/#builders/79/builds/0',
'state': 'SUCCESSFUL',
'key': u'Builder0',
'name': u'Builder0'}),
call('https://bitbucket.org/site/oauth2/access_token',
auth=('key', 'secret'),
data={'grant_type': 'client_credentials'}),
call(u'https://api.bitbucket.org/2.0/repositories/user/repo/commit/d34db33fd43db33f/statuses/build',
json={
'url': 'http://localhost:8080/#builders/79/builds/0',
'state': 'FAILED',
'key': u'Builder0',
'name': u'Builder0'})
call(
u'https://api.bitbucket.org/2.0/repositories/user/repo/commit/d34db33fd43db33f/statuses/build',
json={
'url': 'http://localhost:8080/#builders/79/builds/0',
'state': 'FAILED',
'key': u'Builder0',
'name': u'Builder0'})
])


class TestBitbucketStatusPushRepoParsing(unittest.TestCase):

def parse(self, repourl):
return tuple(BitbucketStatusPush.get_owner_and_repo(repourl))

def test_parse_no_scheme(self):
self.assertEqual(('user', 'repo'), self.parse('git@bitbucket.com:user/repo.git'))
self.assertEqual(('user', 'repo'), self.parse('git@bitbucket.com:user/repo'))
self.assertEqual(
('user', 'repo'), self.parse('git@bitbucket.com:user/repo.git'))
self.assertEqual(
('user', 'repo'), self.parse('git@bitbucket.com:user/repo'))

def test_parse_with_scheme(self):
self.assertEqual(('user', 'repo'), self.parse('https://bitbucket.com/user/repo.git'))
self.assertEqual(('user', 'repo'), self.parse('https://bitbucket.com/user/repo'))
self.assertEqual(('user', 'repo'), self.parse(
'https://bitbucket.com/user/repo.git'))
self.assertEqual(
('user', 'repo'), self.parse('https://bitbucket.com/user/repo'))

self.assertEqual(('user', 'repo'), self.parse('ssh://git@bitbucket.com/user/repo.git'))
self.assertEqual(('user', 'repo'), self.parse('ssh://git@bitbucket.com/user/repo'))
self.assertEqual(('user', 'repo'), self.parse(
'ssh://git@bitbucket.com/user/repo.git'))
self.assertEqual(
('user', 'repo'), self.parse('ssh://git@bitbucket.com/user/repo'))
45 changes: 28 additions & 17 deletions master/buildbot/test/unit/test_reporters_hipchat.py
Expand Up @@ -16,6 +16,7 @@
from mock import call
from twisted.internet import defer
from twisted.trial import unittest

from buildbot import config
from buildbot.process.results import SUCCESS
from buildbot.reporters.hipchat import HipChatStatusPush
Expand All @@ -28,7 +29,8 @@ class TestHipchatStatusPush(unittest.TestCase, ReporterTestMixin):
def setUp(self):
# ignore config error if txrequests is not installed
config._errors = Mock()
self.master = fakemaster.make_master(testcase=self, wantData=True, wantDb=True, wantMq=True)
self.master = fakemaster.make_master(
testcase=self, wantData=True, wantDb=True, wantMq=True)

@defer.inlineCallbacks
def tearDown(self):
Expand Down Expand Up @@ -63,30 +65,34 @@ def test_endpointTypeCheck(self):
@defer.inlineCallbacks
def test_builderRoomMapTypeCheck(self):
yield self.createReporter(builder_room_map=2)
config._errors.addError.assert_any_call('builder_room_map must be a dict')
config._errors.addError.assert_any_call(
'builder_room_map must be a dict')

@defer.inlineCallbacks
def test_builderUserMapTypeCheck(self):
yield self.createReporter(builder_user_map=2)
config._errors.addError.assert_any_call('builder_user_map must be a dict')
config._errors.addError.assert_any_call(
'builder_user_map must be a dict')

@defer.inlineCallbacks
def test_build_started(self):
yield self.createReporter(builder_user_map={'Builder0': '123'})
build = yield self.setupBuildResults()
self.sp.buildStarted(('build', 20, 'new'), build)
expected = [call('https://api.hipchat.com/v2/user/123/message?auth_token=abc',
{'message': 'Buildbot started build Builder0 here: http://localhost:8080/#builders/79/builds/0'})]
expected = [call(
'https://api.hipchat.com/v2/user/123/message?auth_token=abc',
{'message': 'Buildbot started build Builder0 here: http://localhost:8080/#builders/79/builds/0'})]
self.assertEqual(self.sp.session.post.mock_calls, expected)

@defer.inlineCallbacks
def test_build_finished(self):
yield self.createReporter(builder_room_map={'Builder0': '123'})
build = yield self.setupBuildResults()
self.sp.buildFinished(('build', 20, 'finished'), build)
expected = [call('https://api.hipchat.com/v2/room/123/notification?auth_token=abc',
{'message': 'Buildbot finished build Builder0 with result success '
'here: http://localhost:8080/#builders/79/builds/0'})]
expected = [call(
'https://api.hipchat.com/v2/room/123/notification?auth_token=abc',
{'message': 'Buildbot finished build Builder0 with result success '
'here: http://localhost:8080/#builders/79/builds/0'})]
self.assertEqual(self.sp.session.post.mock_calls, expected)

@defer.inlineCallbacks
Expand All @@ -96,10 +102,11 @@ def test_inject_extra_params(self):
self.sp.getExtraParams.return_value = {'format': 'html'}
build = yield self.setupBuildResults()
self.sp.buildFinished(('build', 20, 'finished'), build)
expected = [call('https://api.hipchat.com/v2/room/123/notification?auth_token=abc',
{'message': 'Buildbot finished build Builder0 with result success '
'here: http://localhost:8080/#builders/79/builds/0',
'format': 'html'})]
expected = [call(
'https://api.hipchat.com/v2/room/123/notification?auth_token=abc',
{'message': 'Buildbot finished build Builder0 with result success '
'here: http://localhost:8080/#builders/79/builds/0',
'format': 'html'})]
self.assertEqual(self.sp.session.post.mock_calls, expected)

@defer.inlineCallbacks
Expand Down Expand Up @@ -127,7 +134,8 @@ def test_private_message_sent_with_user_id(self):
postData.update({'id_or_email': '123'})
self.sp.getBuildDetailsAndSendMessage.return_value = postData
self.sp.send({}, 'test')
expected = [call('%s/v2/user/123/message?auth_token=%s' % (endpoint, token), message)]
expected = [
call('%s/v2/user/123/message?auth_token=%s' % (endpoint, token), message)]
self.assertEqual(self.sp.session.post.mock_calls, expected)

@defer.inlineCallbacks
Expand All @@ -141,7 +149,8 @@ def test_room_message_sent_with_room_id(self):
postData.update({'room_id_or_name': '123'})
self.sp.getBuildDetailsAndSendMessage.return_value = postData
self.sp.send({}, 'test')
expected = [call('%s/v2/room/123/notification?auth_token=%s' % (endpoint, token), message)]
expected = [
call('%s/v2/room/123/notification?auth_token=%s' % (endpoint, token), message)]
self.assertEqual(self.sp.session.post.mock_calls, expected)

@defer.inlineCallbacks
Expand All @@ -155,8 +164,9 @@ def test_private_and_room_message_sent_with_both_ids(self):
postData.update({'room_id_or_name': '123', 'id_or_email': '456'})
self.sp.getBuildDetailsAndSendMessage.return_value = postData
self.sp.send({}, 'test')
expected = [call('%s/v2/user/456/message?auth_token=%s' % (endpoint, token), message),
call('%s/v2/room/123/notification?auth_token=%s' % (endpoint, token), message)]
expected = [call(
'%s/v2/user/456/message?auth_token=%s' % (endpoint, token), message),
call('%s/v2/room/123/notification?auth_token=%s' % (endpoint, token), message)]
self.assertEqual(self.sp.session.post.mock_calls, expected)

@defer.inlineCallbacks
Expand All @@ -170,5 +180,6 @@ def test_postData_values_passed_through(self):
postData.update({'id_or_email': '123'})
self.sp.getBuildDetailsAndSendMessage.return_value = postData
self.sp.send({}, 'test')
expected = [call('%s/v2/user/123/message?auth_token=%s' % (endpoint, token), message)]
expected = [
call('%s/v2/user/123/message?auth_token=%s' % (endpoint, token), message)]
self.assertEqual(self.sp.session.post.mock_calls, expected)
2 changes: 0 additions & 2 deletions master/buildbot/www/oauth2.py
Expand Up @@ -15,11 +15,9 @@
from posixpath import join

import requests

from future.moves.urllib.parse import parse_qs
from future.moves.urllib.parse import urlencode
from future.utils import iteritems

from twisted.internet import defer
from twisted.internet import threads

Expand Down
2 changes: 1 addition & 1 deletion master/contrib/hgbuildbot.py
Expand Up @@ -143,8 +143,8 @@
import json
import os
import os.path
import requests

import requests

from mercurial.encoding import fromlocal
from mercurial.node import hex
Expand Down

0 comments on commit e439b49

Please sign in to comment.