Factoids: Prevent empty key or value when adding a factoid.

Signed-off-by: James Vega <jamessan@users.sourceforge.net>
(cherry picked from commit 10f5a12b7e)
This commit is contained in:
James Vega 2010-02-05 18:50:03 -05:00
parent e13d3d6943
commit 0933621dab
2 changed files with 6 additions and 1 deletions

View File

@ -1,6 +1,6 @@
###
# Copyright (c) 2002-2005, Jeremiah Fincher
# Copyright (c) 2009, James Vega
# Copyright (c) 2009-2010, James Vega
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
@ -63,6 +63,8 @@ def getFactoid(irc, msg, args, state):
key.append(args.pop(0))
else:
value.append(args.pop(0))
if not key or not value:
raise callbacks.ArgumentError
state.args.append(' '.join(key))
state.args.append(' '.join(value))

View File

@ -1,5 +1,6 @@
###
# Copyright (c) 2002-2005, Jeremiah Fincher
# Copyright (c) 2010, James Vega
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
@ -43,6 +44,8 @@ if sqlite:
self.assertRegexp('random', 'primary author')
def testLearn(self):
self.assertError('learn as my primary author')
self.assertError('learn jemfinch as')
self.assertNotError('learn jemfinch as my primary author')
self.assertNotError('info jemfinch')
self.assertRegexp('whatis jemfinch', 'my primary author')