mirror of
https://github.com/Mikaela/Limnoria.git
synced 2025-01-23 02:24:12 +01:00
Added assertAction to PluginTestCase.
This commit is contained in:
parent
6150a21ba3
commit
cfb4a0ba07
16
test/test.py
16
test/test.py
@ -141,8 +141,9 @@ class PluginTestCase(unittest.TestCase):
|
||||
def _feedMsg(self, query, timeout=None):
|
||||
if timeout is None:
|
||||
timeout = self.timeout
|
||||
self.irc.feedMsg(ircmsgs.privmsg(self.irc.nick, query,
|
||||
prefix=self.prefix))
|
||||
msg = ircmsgs.privmsg(self.irc.nick, query, prefix=self.prefix)
|
||||
#debug.printf(msg)
|
||||
self.irc.feedMsg(msg)
|
||||
fed = time.time()
|
||||
response = self.irc.takeMsg()
|
||||
while response is None and time.time() - fed < timeout:
|
||||
@ -152,7 +153,7 @@ class PluginTestCase(unittest.TestCase):
|
||||
return response
|
||||
|
||||
def getMsg(self, query, timeout=None):
|
||||
return self._feedMsg(query)
|
||||
return self._feedMsg(query, timeout=timeout)
|
||||
|
||||
def feedMsg(self, query):
|
||||
"""Just feeds it a message, that's all."""
|
||||
@ -227,6 +228,15 @@ class PluginTestCase(unittest.TestCase):
|
||||
for (m, expected) in zip(responses, expectedResponses):
|
||||
self.assertEqual(m.args[1], expected)
|
||||
|
||||
def assertAction(self, query, expectedResponse=None):
|
||||
m = self._feedMsg(query)
|
||||
if m is None:
|
||||
raise TimeoutError, query
|
||||
self.failUnless(ircmsgs.isAction(m))
|
||||
if expectedResponse is not None:
|
||||
self.assertEqual(ircmsgs.unAction(m), expectedResponse)
|
||||
|
||||
|
||||
class ChannelPluginTestCase(PluginTestCase):
|
||||
channel = '#test'
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user