Skip to content

Commit

Permalink
Merge pull request #2368 from rodrigc/stringlower
Browse files Browse the repository at this point in the history
capitalize(), lower(), and join() are gone from the string module in …
  • Loading branch information
Mikhail Sobolev committed Aug 27, 2016
2 parents 59b2374 + fa8bbad commit 4efacaf
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 10 deletions.
10 changes: 3 additions & 7 deletions master/buildbot/reporters/words.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,6 @@
import random
import re
import shlex
from string import capitalize
from string import join
from string import lower

from future.builtins import range
from twisted.internet import defer
Expand Down Expand Up @@ -586,17 +583,16 @@ def notify_for_finished(self, build):
if self.notify_for('finished'):
defer.returnValue(True)

if self.notify_for(lower(self.results_descriptions.get(build['results'])[0])):
if self.notify_for(self.results_descriptions.get(build['results'])[0].lower()):
defer.returnValue(True)

prevBuild = yield self.master.data.get(('builders', build['builderid'], 'builds', build['number'] - 1))
if prevBuild:
prevResult = prevBuild['results']

required_notification_control_string = join((lower(self.results_descriptions.get(prevResult)[0]),
required_notification_control_string = ''.join((self.results_descriptions.get(prevResult)[0].lower(),
'To',
capitalize(self.results_descriptions.get(build['results'])[0])),
'')
self.results_descriptions.get(build['results'])[0].capitalize()))

if (self.notify_for(required_notification_control_string)):
defer.returnValue(True)
Expand Down
5 changes: 2 additions & 3 deletions master/buildbot/steps/source/svn.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
import re
import xml.dom.minidom
import xml.parsers.expat
from string import lower

from future.moves.urllib.parse import quote as urlquote
from future.moves.urllib.parse import unquote as urlunquote
Expand Down Expand Up @@ -431,15 +430,15 @@ def svnUriCanonicalize(uri):
return uri

(scheme, authority, path, parameters, query, fragment) = urlparse(uri)
scheme = lower(scheme)
scheme = scheme.lower()
if authority:
mo = server_authority.match(authority)
if not mo:
return uri # give up
userinfo, host, port = mo.groups()
if host[-1] == '.':
host = host[:-1]
authority = lower(host)
authority = host.lower()
if userinfo:
authority = "%s@%s" % (userinfo, authority)
if port and port != default_port.get(scheme, None):
Expand Down
50 changes: 50 additions & 0 deletions master/buildbot/test/unit/test_reporters_words.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,46 @@ def test_command_mute(self):
yield self.do_test_command('mute')
self.assertTrue(self.contact.muted)

@defer.inlineCallbacks
def test_command_notify0(self):
yield self.do_test_command('notify', exp_UsageError=True)
yield self.do_test_command('notify', args="invalid arg", exp_UsageError=True)
yield self.do_test_command('notify', args="on")
self.assertEqual(self.sent, ["The following events are being notified: ['started', 'finished']"])
yield self.do_test_command('notify', args="off")
self.assertEqual(self.sent, ['The following events are being notified: []'])
yield self.do_test_command('notify', args="on started")
self.assertEqual(self.sent, ["The following events are being notified: ['started']"])
yield self.do_test_command('notify', args="off started")
self.assertEqual(self.sent, ['The following events are being notified: []'])
yield self.assertFailure(
self.do_test_command('notify', args="off finished"),
KeyError)
yield self.do_test_command('notify', args="list")
self.assertEqual(self.sent, ['The following events are being notified: []'])

@defer.inlineCallbacks
def notify_build_test(self, notify_args):
self.bot.tags = None
yield self.test_command_watch_builder0()
yield self.do_test_command('notify', args=notify_args)
buildStarted = self.contact.subscribed[0].callback
buildFinished = self.contact.subscribed[1].callback
for buildid in (13, 14, 16):
self.master.db.builds.finishBuild(buildid=buildid, results=SUCCESS)
build = yield self.master.db.builds.getBuild(buildid)
buildStarted("somekey", build)
buildFinished("somekey", build)

def test_command_notify_build_started(self):
self.notify_build_test("on started")

def test_command_notify_build_finished(self):
self.notify_build_test("on finished")

def test_command_notify_build_started_finished(self):
self.notify_build_test("on")

@defer.inlineCallbacks
def test_command_unmute(self):
self.contact.muted = True
Expand Down Expand Up @@ -473,6 +513,16 @@ def test_command_watch_builder0_get_notifications(self):
self.assertIn(
'Hey! build builder1 #6 is complete: Success []', self.sent)

@defer.inlineCallbacks
def test_command_watch_builder1(self):
self.setupSomeBuilds()
yield self.do_test_command('watch', args=self.BUILDER_NAMES[0])
self.assertEqual(len(self.sent), 2)
self.assertIn(
'watching build builder1 #3 until it finishes..', self.sent)
self.assertIn(
'watching build builder1 #6 until it finishes..', self.sent)

@defer.inlineCallbacks
def sendBuildFinishedMessage(self, buildid, results=0):
self.master.db.builds.finishBuild(buildid=buildid, results=SUCCESS)
Expand Down

0 comments on commit 4efacaf

Please sign in to comment.