mirror of
https://github.com/Mikaela/Limnoria.git
synced 2024-12-23 19:22:45 +01:00
tests.py: wAdded Refresh and Restore tests. plugin.py: Empty lastTopics[channel] raise a KeyError for testing purposes.
This commit is contained in:
parent
54ee1e7670
commit
16ffdf69eb
@ -515,6 +515,8 @@ class Topic(callbacks.Plugin):
|
||||
irc.errorNoCapability(capabilities, Raise=True)
|
||||
try:
|
||||
topics = self.lastTopics[channel]
|
||||
if not topics:
|
||||
raise KeyError
|
||||
except KeyError:
|
||||
irc.error(format(_('I haven\'t yet set the topic in %s.'),
|
||||
channel))
|
||||
@ -535,9 +537,17 @@ class Topic(callbacks.Plugin):
|
||||
topic = irc.state.channels[channel].topic
|
||||
if topic:
|
||||
self._sendTopics(irc, channel, topic)
|
||||
else:
|
||||
self.restore(irc, msg, args, channel)
|
||||
set = wrap(refresh, ['canChangetopic'])
|
||||
return
|
||||
try:
|
||||
topics = self.lastTopics[channel]
|
||||
if not topics:
|
||||
raise KeyError
|
||||
except KeyError:
|
||||
irc.error(format(_('I haven\'t yet set the topic in %s.'),
|
||||
channel))
|
||||
return
|
||||
self._sendTopics(irc, channel, topics)
|
||||
refresh = wrap(refresh, ['canChangeTopic'])
|
||||
|
||||
@internationalizeDocstring
|
||||
def undo(self, irc, msg, args, channel):
|
||||
|
@ -162,6 +162,20 @@ class TopicTestCase(ChannelPluginTestCase):
|
||||
finally:
|
||||
conf.supybot.plugins.Topic.format.setValue(orig)
|
||||
|
||||
def testRestore(self):
|
||||
self.getMsg('topic set foo')
|
||||
self.assertResponse('topic restore', 'foo')
|
||||
self.getMsg('topic remove 1')
|
||||
restoreError = 'Error: I haven\'t yet set the topic in #test.'
|
||||
self.assertResponse('topic restore', restoreError)
|
||||
|
||||
def testRefresh(self):
|
||||
self.getMsg('topic set foo')
|
||||
self.assertResponse('topic refresh', 'foo')
|
||||
self.getMsg('topic remove 1')
|
||||
refreshError = 'Error: I haven\'t yet set the topic in #test.'
|
||||
self.assertResponse('topic refresh', refreshError)
|
||||
|
||||
def testUndo(self):
|
||||
try:
|
||||
original = conf.supybot.plugins.Topic.format()
|
||||
|
Loading…
Reference in New Issue
Block a user