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

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

View File

@ -1,6 +1,6 @@
### ###
# Copyright (c) 2002-2005, Jeremiah Fincher # Copyright (c) 2002-2005, Jeremiah Fincher
# Copyright (c) 2009, James Vega # Copyright (c) 2009-2010, James Vega
# All rights reserved. # All rights reserved.
# #
# Redistribution and use in source and binary forms, with or without # 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)) key.append(args.pop(0))
else: else:
value.append(args.pop(0)) value.append(args.pop(0))
if not key or not value:
raise callbacks.ArgumentError
state.args.append(' '.join(key)) state.args.append(' '.join(key))
state.args.append(' '.join(value)) state.args.append(' '.join(value))

View File

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