plugins/Quotes.py: addquote now announces the id of the new quote

test/test_Quotes.py: updated to reflect change in plugin
This commit is contained in:
James Vega 2003-09-12 13:23:09 +00:00
parent 91274d3f54
commit f524ec0ac9
2 changed files with 5 additions and 5 deletions

View File

@ -89,9 +89,9 @@ class Quotes(ChannelDBHandler, callbacks.Privmsg):
VALUES(NULL, %s, %s, %s)""", VALUES(NULL, %s, %s, %s)""",
msg.nick, quotetime, quote) msg.nick, quotetime, quote)
db.commit() db.commit()
criteria = ['added_by=%s' % msg.nick] criteria = ['added_by="%s"' % msg.nick]
criteria.append('added_at=%s' % quotetime) criteria.append('added_at=%s' % quotetime)
criteria.append('quote=%s' % quote) criteria.append('quote="%s"' % quote)
sql = """SELECT id FROM quotes WHERE %s""" % ' AND '.join(criteria) sql = """SELECT id FROM quotes WHERE %s""" % ' AND '.join(criteria)
cursor.execute(sql) cursor.execute(sql)
quoteid = cursor.fetchone()[0] quoteid = cursor.fetchone()[0]

View File

@ -35,14 +35,14 @@ class QuotesTestCase(PluginTestCase, PluginDocumentation):
plugins = ('Quotes',) plugins = ('Quotes',)
def test(self): def test(self):
self.assertRegexp('numquotes #foo', '0') self.assertRegexp('numquotes #foo', '0')
self.assertNotError('addquote #foo foo') self.assertRegexp('addquote #foo foo', 'Quote #1 added')
self.assertRegexp('numquotes #foo', '1') self.assertRegexp('numquotes #foo', '1')
self.assertResponse('quote #foo --id 1', '#1: foo') self.assertResponse('quote #foo --id 1', '#1: foo')
self.assertResponse('quote #foo 1', '#1: foo') self.assertResponse('quote #foo 1', '#1: foo')
self.assertNotError('addquote #foo bar') self.assertRegexp('addquote #foo bar','Quote #2 added')
self.assertResponse('quote #foo 2', '#2: bar') self.assertResponse('quote #foo 2', '#2: bar')
self.assertResponse('quote #foo --id 2', '#2: bar') self.assertResponse('quote #foo --id 2', '#2: bar')
self.assertNotError('addquote #foo baz') self.assertRegexp('addquote #foo baz','Quote #3 added')
self.assertRegexp('numquotes #foo', '3') self.assertRegexp('numquotes #foo', '3')
self.assertResponse('quote #foo 3', '#3: baz') self.assertResponse('quote #foo 3', '#3: baz')
self.assertRegexp('quote #foo --regexp m/ba/', 'bar.*baz') self.assertRegexp('quote #foo --regexp m/ba/', 'bar.*baz')