Author: David Schneider <david.schnei...@picle.org> Branch: buildbot-0.8.7 Changeset: r809:83ae0f7c3a32 Date: 2013-04-28 19:12 +0200 http://bitbucket.org/pypy/buildbot/changeset/83ae0f7c3a32/
Log: fix tests for ircbot diff --git a/bot2/pypybuildbot/ircbot.py b/bot2/pypybuildbot/ircbot.py --- a/bot2/pypybuildbot/ircbot.py +++ b/bot2/pypybuildbot/ircbot.py @@ -33,7 +33,7 @@ return s -def extract_username(build): +def get_build_information(build): owner = build.getProperty("owner") reason = build.getProperty("reason") return ": ".join(k for k in (owner, reason) if k) @@ -42,9 +42,9 @@ def get_description_for_build(url, build): url = color(url, 'GRAY') # in gray infos = [] - username = extract_username(build) - if username: - infos.append(color(username, 'BLUE')) # in blue + buildinfo = get_build_information(build) + if buildinfo: + infos.append(color(buildinfo, 'BLUE')) # in blue # branch = build.getProperty('branch') if branch: diff --git a/bot2/pypybuildbot/test/test_ircbot.py b/bot2/pypybuildbot/test/test_ircbot.py --- a/bot2/pypybuildbot/test/test_ircbot.py +++ b/bot2/pypybuildbot/test/test_ircbot.py @@ -1,50 +1,48 @@ from pypybuildbot import ircbot + def setup_module(mod): ircbot.USE_COLOR_CODES = False + def teardown_module(mod): ircbot.USE_COLOR_CODES = True + class FakeBuild(object): - def __init__(self, reason=None, source=None): - self.reason = reason - self.source = source + def __init__(self, reason=None, owner=None, branch=None): + self.properties = {'owner': owner, 'branch': branch, 'reason': reason} - def getReason(self): - return self.reason + def getProperty(self, name): + return self.properties.get(name, None) - def getSourceStamp(self): - return self.source -class FakeSource(object): - - def __init__(self, branch): - self.branch = branch - -def test_extract_username(): - a = FakeBuild("The web-page 'force build' button was pressed by 'antocuni': foo") +def test_get_build_information(): + a = FakeBuild(owner='antocuni', + reason="The web-page 'force build' button was pressed") b = FakeBuild("The web-page 'force build' button was ...") - assert ircbot.extract_username(a) == 'antocuni' - assert ircbot.extract_username(b) is None + assert ircbot.get_build_information(a) == \ + "antocuni: The web-page 'force build' button was pressed" + assert ircbot.get_build_information(b) == \ + "The web-page 'force build' button was ..." def test_get_description_for_build(): - a = FakeBuild('foobar', source=FakeSource(None)) + a = FakeBuild() msg = ircbot.get_description_for_build("http://myurl", a) assert msg == "http://myurl" - a = FakeBuild("The web-page 'force build' button was pressed by 'antocuni': foo", - source=FakeSource(None)) + a = FakeBuild(owner='antocuni', + reason="The web-page 'force build' button was pressed") msg = ircbot.get_description_for_build("http://myurl", a) - assert msg == "http://myurl [antocuni]" + assert msg == "http://myurl [antocuni: " \ + + "The web-page 'force build' button was pressed]" - a = FakeBuild('foobar', source=FakeSource('mybranch')) + a = FakeBuild(branch='mybranch') msg = ircbot.get_description_for_build("http://myurl", a) assert msg == "http://myurl [mybranch]" - a = FakeBuild("The web-page 'force build' button was pressed by 'antocuni': foo", - source=FakeSource('mybranch')) + a = FakeBuild(owner='antocuni', branch='mybranch') msg = ircbot.get_description_for_build("http://myurl", a) assert msg == "http://myurl [antocuni, mybranch]" _______________________________________________ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit