mirror of
https://github.com/Mikaela/Limnoria.git
synced 2024-11-27 13:19:24 +01:00
Added assertNoError to PluginTestCase
This commit is contained in:
parent
d25b3894d7
commit
0415251146
29
test/test.py
29
test/test.py
@ -98,29 +98,32 @@ class PluginTestCase(unittest.TestCase):
|
|||||||
plugin = module.Class()
|
plugin = module.Class()
|
||||||
self.irc.addCallback(plugin)
|
self.irc.addCallback(plugin)
|
||||||
|
|
||||||
def assertResponse(self, query, expectedResponse):
|
def _feedMsg(self, query):
|
||||||
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 < self.timeout:
|
||||||
response = self.irc.takeMsg()
|
response = self.irc.takeMsg()
|
||||||
self.failUnless(response)
|
self.failUnless(response)
|
||||||
self.assertEqual(response.args[1], expectedResponse)
|
return response
|
||||||
|
|
||||||
|
def assertNoError(self, query):
|
||||||
|
msg = self._feedMsg(query)
|
||||||
|
self.failIf(msg.args[1].startswith('Error:'))
|
||||||
|
|
||||||
|
def assertResponse(self, query, expectedResponse):
|
||||||
|
msg = self._feedMsg(query)
|
||||||
|
self.assertEqual(msg.args[1], expectedResponse)
|
||||||
|
|
||||||
def assertResponses(self, query, expectedResponses):
|
def assertResponses(self, query, expectedResponses):
|
||||||
self.irc.feedMsg(ircmsgs.privmsg(self.nick, query, prefix=self.prefix))
|
|
||||||
fed = time.time()
|
|
||||||
responses = []
|
responses = []
|
||||||
while len(responses) < len(expectedResponses) and \
|
while len(responses) < len(expectedResponses):
|
||||||
time.time() - fed < self.timeout :
|
msg = self._feedMsg(query)
|
||||||
m = self.irc.takeMsg()
|
self.failUnless(msg)
|
||||||
if m:
|
responses.append(msg)
|
||||||
responses.append(m)
|
|
||||||
else:
|
|
||||||
time.sleep(.1)
|
|
||||||
self.assertEqual(len(expectedResponses), len(responses))
|
self.assertEqual(len(expectedResponses), len(responses))
|
||||||
for (response, expected) in zip(responses, expectedResponses):
|
for (msg, expected) in zip(responses, expectedResponses):
|
||||||
self.assertEqual(response.args[1], expected)
|
self.assertEqual(msg.args[1], expected)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
Loading…
Reference in New Issue
Block a user