Fixed an error in hostmask.list when there are no hostmasks.

This commit is contained in:
Jeremy Fincher 2005-06-01 06:20:29 +00:00
parent 5c8677cf22
commit 766dad2f70
2 changed files with 14 additions and 2 deletions

View File

@ -246,8 +246,11 @@ class User(callbacks.Plugin):
"""
def getHostmasks(user):
hostmasks = map(repr, user.hostmasks)
hostmasks.sort()
return format('%L', hostmasks)
if hostmasks:
hostmasks.sort()
return format('%L', hostmasks)
else:
irc.reply(format('%s has no registered hostmasks.', user))
try:
user = ircdb.users.getUser(msg.prefix)
if name:

View File

@ -47,6 +47,15 @@ class UserTestCase(PluginTestCase):
self.assertNotError('hostmask add foo')
self.assertNotRegexp('hostmask add foo', 'IrcSet')
def testHostmaskListHandlesEmptyListGracefully(self):
self.assertError('hostmask list')
self.prefix = self.prefix1
self.assertNotError('register foo bar')
self.assertNotError('hostmask remove foo %s' % self.prefix1)
self.assertNotError('identify foo bar')
self.assertRegexp('hostmask list', 'no registered hostmasks')
def testHostmask(self):
self.assertResponse('hostmask', self.prefix)
self.assertError('@hostmask asdf')