Fix an exception when using the --to option for Note.list and add tests

for the --to and --from options.
This commit is contained in:
James Vega 2005-01-05 18:36:46 +00:00
parent 06307abee1
commit f31fec5681
2 changed files with 3 additions and 6 deletions

View File

@ -373,14 +373,9 @@ class Note(callbacks.Privmsg):
def p(note):
return note.frm == user.id
if receiver:
try:
receiver = ircdb.users.getUserId(receiver)
except KeyError:
irc.error('That user is not in my user database.')
return
originalP = p
def p(note):
return originalP(note) and note.to == receiver
return originalP(note) and note.to == receiver.id
notes = list(self.db.select(p))
if not notes:
irc.error('I couldn\'t find any sent notes for your user.')

View File

@ -70,9 +70,11 @@ class NoteTestCase(PluginTestCase, PluginDocumentation):
self.assertNotError('note send inkedmn 1,2,3')
_ = self.getMsg(' ')
self.assertRegexp('note list --sent', r'#2.*#1')
self.assertRegexp('note list --sent --to inkedmn', r'#2.*#1')
self.assertRegexp('note list', r'#1.*#2')
self.assertRegexp('note 1', 'testing')
self.assertResponse('note list --old', '#1 from inkedmn')
self.assertResponse('note list --old --from inkedmn','#1 from inkedmn')