mirror of https://github.com/Mikaela/Limnoria.git
Now Todo.remove can take multiple taskids to be removed instead of just one
This commit is contained in:
parent
c6d77bb923
commit
0c3c37b4ba
|
@ -211,7 +211,7 @@ class Todo(callbacks.Privmsg):
|
|||
irc.reply(msg, '%s (Todo #%s added)' % (conf.replySuccess, todoId))
|
||||
|
||||
def remove(self, irc, msg, args):
|
||||
"""<task id>
|
||||
"""<task id> [<task id> ...]
|
||||
|
||||
Removes <task id> from your personal todo list.
|
||||
"""
|
||||
|
@ -220,16 +220,28 @@ class Todo(callbacks.Privmsg):
|
|||
except KeyError:
|
||||
irc.error(msg, conf.replyNotRegistered)
|
||||
return
|
||||
taskid = privmsgs.getArgs(args)
|
||||
taskids = privmsgs.getArgs(args)
|
||||
tasks = taskids.split()
|
||||
#print 'Tasks: %s' % repr(tasks)
|
||||
db = self.dbHandler.getDb()
|
||||
cursor = db.cursor()
|
||||
invalid = []
|
||||
for taskid in tasks:
|
||||
cursor.execute("""SELECT * FROM todo
|
||||
WHERE id = %s AND userid = %s
|
||||
AND active = 1""", taskid, id)
|
||||
#print 'Rowcount: %s' % cursor.rowcount
|
||||
if cursor.rowcount == 0:
|
||||
irc.error(msg, 'None of your tasks match that id.')
|
||||
return
|
||||
cursor.execute("""UPDATE todo SET active = 0 WHERE id = %s""", taskid)
|
||||
invalid.append(taskid)
|
||||
#print 'Invalid tasks: %s' % repr(invalid)
|
||||
if invalid:
|
||||
irc.error(msg, 'No tasks were removed because the following '\
|
||||
'tasks could not be removed: %s' % \
|
||||
utils.commaAndify(invalid))
|
||||
else:
|
||||
for taskid in tasks:
|
||||
cursor.execute("""UPDATE todo SET active = 0 WHERE id = %s""",
|
||||
taskid)
|
||||
db.commit()
|
||||
irc.reply(msg, conf.replySuccess)
|
||||
|
||||
|
|
|
@ -39,10 +39,14 @@ except ImportError:
|
|||
if sqlite is not None:
|
||||
class TodoTestCase(PluginTestCase, PluginDocumentation):
|
||||
plugins = ('Todo', 'User')
|
||||
_user1 = 'foo!bar@baz'
|
||||
_user2 = 'bar!foo@baz'
|
||||
def setUp(self):
|
||||
PluginTestCase.setUp(self)
|
||||
# Create a valid user to use
|
||||
self.prefix = 'foo!bar@baz'
|
||||
self.prefix = self._user2
|
||||
self.assertNotError('register testy oom')
|
||||
self.prefix = self._user1
|
||||
self.assertNotError('register tester moo')
|
||||
|
||||
def testTodo(self):
|
||||
|
@ -77,9 +81,28 @@ if sqlite is not None:
|
|||
self.assertNotError('todo add --priority=1000 fix all bugs')
|
||||
|
||||
def testRemovetodo(self):
|
||||
self.nick = 'testy'
|
||||
self.prefix = self._user2
|
||||
self.assertNotError('todo add do something')
|
||||
self.assertNotError('todo add do something else')
|
||||
self.assertNotError('todo add do something again')
|
||||
self.assertNotError('todo remove 1')
|
||||
self.assertNotError('todo 1')
|
||||
self.nick = 'tester'
|
||||
self.prefix = self._user1
|
||||
self.assertNotError('todo add make something')
|
||||
self.assertNotError('todo add make something else')
|
||||
self.assertNotError('todo add make something again')
|
||||
self.assertError('todo remove 2 4')
|
||||
self.assertNotRegexp('todo 2', r'Inactive')
|
||||
self.assertNotRegexp('todo 4', r'Inactive')
|
||||
self.assertError('todo remove 2')
|
||||
self.assertNotRegexp('todo 2', r'Inactive')
|
||||
self.assertNotError('todo')
|
||||
self.assertNotError('todo remove 4 5')
|
||||
self.assertNotError('todo')
|
||||
self.assertRegexp('todo 4', r'Inactive')
|
||||
self.assertRegexp('todo 5', r'Inactive')
|
||||
|
||||
def testSearchtodo(self):
|
||||
self.assertNotError('todo add task number one')
|
||||
|
|
Loading…
Reference in New Issue