Fixed ordering by priority when requesting todos for a person (or self)

This commit is contained in:
Daniel DiPaolo 2003-10-29 20:12:02 +00:00
parent 70be390875
commit 8cc9620a4b
2 changed files with 11 additions and 5 deletions

View File

@ -125,7 +125,8 @@ class Todo(callbacks.Privmsg):
return
cursor = self.db.cursor()
cursor.execute("""SELECT id, task FROM todo
WHERE userid = %s AND active = 1""", id)
WHERE userid = %s AND active = 1
ORDER BY priority, id""", id)
if cursor.rowcount == 0:
irc.reply(msg, 'You have no tasks in your todo list.')
return
@ -136,7 +137,8 @@ class Todo(callbacks.Privmsg):
cursor = self.db.cursor()
if userid:
cursor.execute("""SELECT id, task FROM todo
WHERE userid = %s AND active = 1""", userid)
WHERE userid = %s AND active = 1
ORDER BY priority, id""", userid)
if cursor.rowcount == 0:
irc.reply(msg, 'That user has no todos.')
return

View File

@ -48,15 +48,15 @@ if sqlite is not None:
def testTodo(self):
# Should not error, but no tasks yet.
self.assertNotError('todo')
self.assertRegexp('todo', 'You have no tasks in your todo list.')
self.assertResponse('todo', 'You have no tasks in your todo list.')
# Add a task
self.assertNotError('todo add wash my car')
self.assertRegexp('todo', '#1: wash my car')
self.assertResponse('todo', '#1: wash my car')
# Check that task
self.assertRegexp('todo 1',
'Todo for tester: wash my car \(Added .*?\)')
# Check that it lists all my tasks when given my name
self.assertRegexp('todo tester', 'Todo for tester: '
self.assertResponse('todo tester', 'Todo for tester: '
'#1: wash my car')
# Check pluralization
self.assertNotError('todo add moo')
@ -66,6 +66,10 @@ if sqlite is not None:
self.assertError('todo asfas')
self.assertResponse('todo asfas', 'Error: \'asfas\' is not a '
'valid task id or username')
# Check priority sorting
self.assertNotError('todo setpriority 1 100')
self.assertNotError('todo setpriority 2 10')
self.assertResponse('todo', '#2: moo and #1: wash my car')
def testAddtodo(self):
self.assertNotError('todo add code a new plugin')