aboutsummaryrefslogtreecommitdiffstats
path: root/local
diff options
context:
space:
mode:
authorkongr45gpen <electrovesta@gmail.com>2014-04-28 00:16:14 +0300
committerkongr45gpen <electrovesta@gmail.com>2014-04-28 00:16:14 +0300
commitb4c587246e389b72019f76515dc04e0e13b92eb6 (patch)
tree62d777f222b7925b66ec10635385b92560973f5e /local
parent8afc8e3105c89115c4327f83041bb96796c894ef (diff)
downloadsupybot_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.py46
-rw-r--r--local/handler/PushHandler.py1
-rw-r--r--local/utility.py2
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

© 2014-2024 Faster IT GmbH | imprint | privacy policy