mirror of https://github.com/Mikaela/Limnoria.git
Maintainability updates.
This commit is contained in:
parent
f099a53374
commit
5603c62f38
|
@ -208,8 +208,8 @@ class PluginTestCase(SupyTestCase):
|
||||||
# do them would be to use a proxy for the irc object and intercept .error.
|
# do them would be to use a proxy for the irc object and intercept .error.
|
||||||
# But that would be hard, so I don't bother. When this breaks, it'll get
|
# But that would be hard, so I don't bother. When this breaks, it'll get
|
||||||
# fixed, but not until then.
|
# fixed, but not until then.
|
||||||
def assertError(self, query, to=None, frm=None):
|
def assertError(self, query, **kwargs):
|
||||||
m = self._feedMsg(query, to=to, frm=frm)
|
m = self._feedMsg(query, **kwargs)
|
||||||
if m is None:
|
if m is None:
|
||||||
raise TimeoutError, query
|
raise TimeoutError, query
|
||||||
if lastGetHelp not in m.args[1]:
|
if lastGetHelp not in m.args[1]:
|
||||||
|
@ -217,8 +217,8 @@ class PluginTestCase(SupyTestCase):
|
||||||
'%r did not error: %s' % (query, m.args[1]))
|
'%r did not error: %s' % (query, m.args[1]))
|
||||||
return m
|
return m
|
||||||
|
|
||||||
def assertNotError(self, query, to=None, frm=None):
|
def assertNotError(self, query, **kwargs):
|
||||||
m = self._feedMsg(query, to=to, frm=frm)
|
m = self._feedMsg(query, **kwargs)
|
||||||
if m is None:
|
if m is None:
|
||||||
raise TimeoutError, query
|
raise TimeoutError, query
|
||||||
self.failIf(m.args[1].startswith('Error:'),
|
self.failIf(m.args[1].startswith('Error:'),
|
||||||
|
@ -227,45 +227,45 @@ class PluginTestCase(SupyTestCase):
|
||||||
'%r returned the help string.' % query)
|
'%r returned the help string.' % query)
|
||||||
return m
|
return m
|
||||||
|
|
||||||
def assertHelp(self, query, to=None, frm=None):
|
def assertHelp(self, query, **kwargs):
|
||||||
m = self._feedMsg(query, to=to, frm=frm)
|
m = self._feedMsg(query, **kwargs)
|
||||||
if m is None:
|
if m is None:
|
||||||
raise TimeoutError, query
|
raise TimeoutError, query
|
||||||
self.failUnless(lastGetHelp in m.args[1],
|
self.failUnless(lastGetHelp in m.args[1],
|
||||||
'%s is not the help (%s)' % (m.args[1], lastGetHelp))
|
'%s is not the help (%s)' % (m.args[1], lastGetHelp))
|
||||||
return m
|
return m
|
||||||
|
|
||||||
def assertNoResponse(self, query, timeout=None, to=None, frm=None):
|
def assertNoResponse(self, query, timeout=0, **kwargs):
|
||||||
m = self._feedMsg(query, timeout=timeout, to=to, frm=frm)
|
m = self._feedMsg(query, timeout=timeout, **kwargs)
|
||||||
self.failIf(m, 'Unexpected response: %r' % m)
|
self.failIf(m, 'Unexpected response: %r' % m)
|
||||||
return m
|
return m
|
||||||
|
|
||||||
def assertResponse(self, query, expectedResponse, to=None, frm=None):
|
def assertResponse(self, query, expectedResponse, **kwargs):
|
||||||
m = self._feedMsg(query, to=to, frm=frm)
|
m = self._feedMsg(query, **kwargs)
|
||||||
if m is None:
|
if m is None:
|
||||||
raise TimeoutError, query
|
raise TimeoutError, query
|
||||||
self.assertEqual(m.args[1], expectedResponse,
|
self.assertEqual(m.args[1], expectedResponse,
|
||||||
'%r != %r' % (expectedResponse, m.args[1]))
|
'%r != %r' % (expectedResponse, m.args[1]))
|
||||||
return m
|
return m
|
||||||
|
|
||||||
def assertRegexp(self, query, regexp, flags=re.I, to=None, frm=None):
|
def assertRegexp(self, query, regexp, flags=re.I, **kwargs):
|
||||||
m = self._feedMsg(query, to=to, frm=frm)
|
m = self._feedMsg(query, **kwargs)
|
||||||
if m is None:
|
if m is None:
|
||||||
raise TimeoutError, query
|
raise TimeoutError, query
|
||||||
self.failUnless(re.search(regexp, m.args[1], flags),
|
self.failUnless(re.search(regexp, m.args[1], flags),
|
||||||
'%r does not match %r' % (m.args[1], regexp))
|
'%r does not match %r' % (m.args[1], regexp))
|
||||||
return m
|
return m
|
||||||
|
|
||||||
def assertNotRegexp(self, query, regexp, flags=re.I, to=None, frm=None):
|
def assertNotRegexp(self, query, regexp, flags=re.I, **kwargs):
|
||||||
m = self._feedMsg(query, to=to, frm=frm)
|
m = self._feedMsg(query, **kwargs)
|
||||||
if m is None:
|
if m is None:
|
||||||
raise TimeoutError, query
|
raise TimeoutError, query
|
||||||
self.failUnless(re.search(regexp, m.args[1], flags) is None,
|
self.failUnless(re.search(regexp, m.args[1], flags) is None,
|
||||||
'%r matched %r' % (m.args[1], regexp))
|
'%r matched %r' % (m.args[1], regexp))
|
||||||
return m
|
return m
|
||||||
|
|
||||||
def assertAction(self, query, expectedResponse=None, to=None, frm=None):
|
def assertAction(self, query, expectedResponse=None, **kwargs):
|
||||||
m = self._feedMsg(query, to=to, frm=frm)
|
m = self._feedMsg(query, **kwargs)
|
||||||
if m is None:
|
if m is None:
|
||||||
raise TimeoutError, query
|
raise TimeoutError, query
|
||||||
self.failUnless(ircmsgs.isAction(m))
|
self.failUnless(ircmsgs.isAction(m))
|
||||||
|
@ -273,8 +273,8 @@ class PluginTestCase(SupyTestCase):
|
||||||
self.assertEqual(ircmsgs.unAction(m), expectedResponse)
|
self.assertEqual(ircmsgs.unAction(m), expectedResponse)
|
||||||
return m
|
return m
|
||||||
|
|
||||||
def assertActionRegexp(self, query, regexp, flags=re.I, to=None, frm=None):
|
def assertActionRegexp(self, query, regexp, flags=re.I, **kwargs):
|
||||||
m = self._feedMsg(query, to=to, frm=frm)
|
m = self._feedMsg(query, **kwargs)
|
||||||
if m is None:
|
if m is None:
|
||||||
raise TimeoutError, query
|
raise TimeoutError, query
|
||||||
self.failUnless(ircmsgs.isAction(m))
|
self.failUnless(ircmsgs.isAction(m))
|
||||||
|
@ -353,10 +353,13 @@ class ChannelPluginTestCase(PluginTestCase):
|
||||||
print 'Returning: %r' % ret
|
print 'Returning: %r' % ret
|
||||||
return ret
|
return ret
|
||||||
|
|
||||||
def feedMsg(self, query):
|
def feedMsg(self, query, to=None, frm=None):
|
||||||
"""Just feeds it a message, that's all."""
|
"""Just feeds it a message, that's all."""
|
||||||
self.irc.feedMsg(ircmsgs.privmsg(self.channel, query,
|
if to is None:
|
||||||
prefix=self.prefix))
|
to = self.channel
|
||||||
|
if frm is None:
|
||||||
|
frm = self.prefix
|
||||||
|
self.irc.feedMsg(ircmsgs.privmsg(to, query, prefix=frm))
|
||||||
|
|
||||||
|
|
||||||
class PluginDocumentation:
|
class PluginDocumentation:
|
||||||
|
|
Loading…
Reference in New Issue