Use 0 when no results are returned for Google.fight

Signed-off-by: James Vega <jamessan@users.sourceforge.net>
This commit is contained in:
James Vega 2009-11-28 21:21:00 -05:00
parent a48cd109a3
commit 3689460d0f
2 changed files with 4 additions and 2 deletions

View File

@ -219,7 +219,8 @@ class Google(callbacks.PluginRegexp):
results = []
for arg in args:
data = self.search(arg, channel, {'smallsearch': True})
count = data['responseData']['cursor']['estimatedResultCount']
count = data['responseData']['cursor'].get('estimatedResultCount',
0)
results.append((int(count), arg))
results.sort()
results.reverse()

View File

@ -1,6 +1,6 @@
###
# Copyright (c) 2002-2004, Jeremiah Fincher
# Copyright (c) 2008, James Vega
# Copyright (c) 2008-2009, James Vega
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
@ -55,6 +55,7 @@ class GoogleTestCase(ChannelPluginTestCase):
def testFight(self):
self.assertRegexp('fight supybot moobot', r'.*supybot.*: \d+')
self.assertNotError('fight ... !')
def testTranslate(self):
self.assertRegexp('translate en es hello world', 'mundo')