Fixed some bugs with note orders, etc.

This commit is contained in:
Jeremy Fincher 2004-08-07 00:48:03 +00:00
parent ec16cf9622
commit 52cbec4838
2 changed files with 34 additions and 37 deletions

View File

@ -394,6 +394,7 @@ class Note(callbacks.Privmsg):
return return
notesAndIds = self.db.notes(p) notesAndIds = self.db.notes(p)
notesAndIds.sort() notesAndIds.sort()
#notesAndIds.reverse() # Newer notes, higher ids.
if not notesAndIds: if not notesAndIds:
irc.reply('You have no unread notes.') irc.reply('You have no unread notes.')
else: else:
@ -434,6 +435,7 @@ class Note(callbacks.Privmsg):
return originalP(note) and note.to == receiver return originalP(note) and note.to == receiver
notesAndIds = self.db.notes(p) notesAndIds = self.db.notes(p)
notesAndIds.sort() notesAndIds.sort()
notesAndIds.reverse()
if not notesAndIds: if not notesAndIds:
irc.error('I couldn\'t find any sent notes for your user.') irc.error('I couldn\'t find any sent notes for your user.')
else: else:
@ -461,6 +463,7 @@ class Note(callbacks.Privmsg):
return originalP(note) and note.frm == sender return originalP(note) and note.frm == sender
notesAndIds = self.db.notes(p) notesAndIds = self.db.notes(p)
notesAndIds.sort() notesAndIds.sort()
notesAndIds.reverse()
if not notesAndIds: if not notesAndIds:
irc.reply('I couldn\'t find any matching read notes for your user.') irc.reply('I couldn\'t find any matching read notes for your user.')
else: else:

View File

@ -34,46 +34,40 @@ from testsupport import *
import supybot.utils as utils import supybot.utils as utils
import supybot.ircdb as ircdb import supybot.ircdb as ircdb
try: class NoteTestCase(PluginTestCase, PluginDocumentation):
import sqlite plugins = ('Note', 'Misc', 'User')
except ImportError: def setUp(self):
sqlite = None PluginTestCase.setUp(self)
# setup a user
self.prefix = 'foo!bar@baz'
self.assertNotError('register inkedmn bar')
if sqlite is not None: def testSendnote(self):
class NoteTestCase(PluginTestCase, PluginDocumentation): #print repr(ircdb.users.getUser(self.prefix))
plugins = ('Note', 'Misc', 'User') self.assertRegexp('note send inkedmn test', '#1')
def setUp(self): # have to getMsg(' ') after each Note.send to absorb supybot's
PluginTestCase.setUp(self) # automatic "You have an unread note" message
# setup a user _ = self.getMsg(' ')
self.prefix = 'foo!bar@baz' self.assertError('note send alsdkjfasldk foo')
self.assertNotError('register inkedmn bar') self.assertNotError('note send inkedmn test2')
_ = self.getMsg(' ')
def testSendnote(self): def testNote(self):
#print repr(ircdb.users.getUser(self.prefix)) self.assertNotError('note send inkedmn test')
self.assertRegexp('note send inkedmn test', '#1') _ = self.getMsg(' ')
# have to getMsg(' ') after each Note.send to absorb supybot's self.assertRegexp('note 1', 'test')
# automatic "You have an unread note" message self.assertError('note blah')
_ = self.getMsg(' ')
self.assertError('note send alsdkjfasldk foo')
self.assertNotError('note send inkedmn test2')
_ = self.getMsg(' ')
def testNote(self): def testList(self):
self.assertNotError('note send inkedmn test') self.assertResponse('note list', 'You have no unread notes.')
_ = self.getMsg(' ') self.assertNotError('note send inkedmn testing')
self.assertRegexp('note 1', 'test') _ = self.getMsg(' ')
self.assertError('note blah') self.assertNotError('note send inkedmn 1,2,3')
_ = self.getMsg(' ')
def testList(self): self.assertRegexp('note list --sent', r'#2.*#1')
self.assertResponse('note list', 'You have no unread notes.') self.assertRegexp('note list', r'#1.*#2')
self.assertNotError('note send inkedmn testing') self.assertRegexp('note 1', 'testing')
_ = self.getMsg(' ') self.assertResponse('note list --old', '#1 from inkedmn')
self.assertNotError('note send inkedmn 1,2,3')
_ = self.getMsg(' ')
self.assertRegexp('note list --sent', r'#2.*#1')
self.assertRegexp('note list', r'#1.*#2')
self.assertRegexp('note 1', 'testing')
self.assertResponse('note list --old', '#1 from inkedmn')