mirror of
https://github.com/Mikaela/Limnoria.git
synced 2024-11-27 13:19:24 +01:00
Added PluginTestCase.{getMsg,assertNoResponse} and a timeout option to some commands.
This commit is contained in:
parent
7851f3a502
commit
6cc3103656
13
test/test.py
13
test/test.py
@ -115,14 +115,19 @@ class PluginTestCase(unittest.TestCase):
|
|||||||
self.irc.die()
|
self.irc.die()
|
||||||
gc.collect()
|
gc.collect()
|
||||||
|
|
||||||
def _feedMsg(self, query):
|
def _feedMsg(self, query, timeout=None):
|
||||||
|
if timeout is None:
|
||||||
|
timeout = self.timeout
|
||||||
self.irc.feedMsg(ircmsgs.privmsg(self.nick, query, prefix=self.prefix))
|
self.irc.feedMsg(ircmsgs.privmsg(self.nick, query, prefix=self.prefix))
|
||||||
fed = time.time()
|
fed = time.time()
|
||||||
response = self.irc.takeMsg()
|
response = self.irc.takeMsg()
|
||||||
while response is None and time.time() - fed < self.timeout:
|
while response is None and time.time() - fed < timeout:
|
||||||
response = self.irc.takeMsg()
|
response = self.irc.takeMsg()
|
||||||
return response
|
return response
|
||||||
|
|
||||||
|
def getMsg(self, query, timeout=None):
|
||||||
|
return self._feedMsg(query)
|
||||||
|
|
||||||
def feedMsg(self, query):
|
def feedMsg(self, query):
|
||||||
"""Just feeds it a message, that's all."""
|
"""Just feeds it a message, that's all."""
|
||||||
self.irc.feedMsg(ircmsgs.privmsg(self.nick, query, prefix=self.prefix))
|
self.irc.feedMsg(ircmsgs.privmsg(self.nick, query, prefix=self.prefix))
|
||||||
@ -143,6 +148,10 @@ class PluginTestCase(unittest.TestCase):
|
|||||||
self.failIf(m.args[1].startswith('Error:'),
|
self.failIf(m.args[1].startswith('Error:'),
|
||||||
'%r errored: %s' % (query, m.args[1]))
|
'%r errored: %s' % (query, m.args[1]))
|
||||||
|
|
||||||
|
def assertNoResponse(self, query, timeout=None):
|
||||||
|
m = self._feedMsg(query, timeout)
|
||||||
|
self.failIf(m)
|
||||||
|
|
||||||
def assertResponse(self, query, expectedResponse):
|
def assertResponse(self, query, expectedResponse):
|
||||||
m = self._feedMsg(query)
|
m = self._feedMsg(query)
|
||||||
self.failUnless(m)
|
self.failUnless(m)
|
||||||
|
Loading…
Reference in New Issue
Block a user