diff options
author | kongr45gpen <electrovesta@gmail.com> | 2014-04-28 00:16:14 +0300 |
---|---|---|
committer | kongr45gpen <electrovesta@gmail.com> | 2014-04-28 00:16:14 +0300 |
commit | b4c587246e389b72019f76515dc04e0e13b92eb6 (patch) | |
tree | 62d777f222b7925b66ec10635385b92560973f5e /local | |
parent | 8afc8e3105c89115c4327f83041bb96796c894ef (diff) | |
download | supybot_github-b4c587246e389b72019f76515dc04e0e13b92eb6.tar.gz supybot_github-b4c587246e389b72019f76515dc04e0e13b92eb6.tar.bz2 supybot_github-b4c587246e389b72019f76515dc04e0e13b92eb6.zip |
Add tests
Diffstat (limited to 'local')
-rw-r--r-- | local/handler/GithubHandler.py | 46 | ||||
-rw-r--r-- | local/handler/PushHandler.py | 1 | ||||
-rw-r--r-- | local/utility.py | 2 |
3 files changed, 25 insertions, 24 deletions
diff --git a/local/handler/GithubHandler.py b/local/handler/GithubHandler.py index ed27a98..ea9f7d4 100644 --- a/local/handler/GithubHandler.py +++ b/local/handler/GithubHandler.py @@ -31,7 +31,6 @@ import IssueCommentHandler class GithubHandler(BaseHTTPServer.BaseHTTPRequestHandler): def do_POST(s): """Respond to a POST request.""" - length = int(s.headers['Content-Length']) post_data = urlparse.parse_qs(s.rfile.read(length).decode('utf-8')) data = json.loads(post_data['payload'][0]) @@ -84,30 +83,33 @@ class GithubHandler(BaseHTTPServer.BaseHTTPRequestHandler): s.wfile.write("The password is wrong") return - for irc in world.ircs: - # Handle different event types - - msgs = [] - - if 'pages' in data: - msgs = WikiHandler.handle(irc, data) - elif 'state' in data: - msgs = StatusHandler.handle(irc, data) - elif 'commits' in data: - msgs = PushHandler.handle(irc, data) - elif 'issue' in data: - if 'comment' in data: - msgs = IssueCommentHandler.handle(irc, data) - else: - msgs = IssueHandler.handle(irc, data) + irc = {} + # Handle different event types + + msgs = [] + + if 'pages' in data: + msgs = WikiHandler.handle(irc, data) + elif 'state' in data: + msgs = StatusHandler.handle(irc, data) + elif 'commits' in data: + msgs = PushHandler.handle(irc, data) + elif 'issue' in data: + if 'comment' in data: + msgs = IssueCommentHandler.handle(irc, data) else: - msgs.append( ircmsgs.privmsg(channel, "Something happened")) + msgs = IssueHandler.handle(irc, data) + else: + msgs.append( ircmsgs.privmsg(channel, "Something happened")) - #msgs.append( ircmsgs.privmsg("#main", "%s" % ()) ) - for msg in msgs: - irc.queueMsg(ircmsgs.privmsg(channel, msg)) - saveMessages(msgs) + saveMessages(msgs) + + #msgs.append( ircmsgs.privmsg("#main", "%s" % ()) ) + if not world.testing: + for msg in msgs: + for irc in world.ircs: + irc.queueMsg(ircmsgs.privmsg(channel, msg)) def log_message(self, format, *args): log.info(format % args) diff --git a/local/handler/PushHandler.py b/local/handler/PushHandler.py index 3ce24f9..4ec927b 100644 --- a/local/handler/PushHandler.py +++ b/local/handler/PushHandler.py @@ -66,7 +66,6 @@ def handle(irc, data): regularCommitCount = len(data['commits']) - mergedCommitCount isMerge = True - if configValue("hidePush",None) == False and not branched: msgs.append( "%s @ %s: %s pushed %s %s (%s)%s" % ( ircutils.bold(ircutils.mircColor(branch, "blue")), diff --git a/local/utility.py b/local/utility.py index abb0915..2640e41 100644 --- a/local/utility.py +++ b/local/utility.py @@ -67,7 +67,7 @@ def getShortURL(longurl): def saveMessages(msgs): """ Saves the last messages so that the plugin can be easily tested """ - if world.testing: + if not world.testing: return globals.messageList = msgs |