From fd6f4e7e24d3c3a44ca485f76e0ae703674dbc38 Mon Sep 17 00:00:00 2001 From: James Vega Date: Wed, 29 Dec 2004 22:30:54 +0000 Subject: [PATCH] Fix a bug where we weren't catching the end of the URL appropriately --- plugins/Gameknot.py | 2 +- test/test_Gameknot.py | 52 +++++++++++++++++++++++++++++-------------- 2 files changed, 36 insertions(+), 18 deletions(-) diff --git a/plugins/Gameknot.py b/plugins/Gameknot.py index 6df47a6ef..a3007a72d 100644 --- a/plugins/Gameknot.py +++ b/plugins/Gameknot.py @@ -226,7 +226,7 @@ class Gameknot(callbacks.PrivmsgCommandAndRegexp): gameknotSnarfer = urlSnarfer(gameknotSnarfer) def gameknotStatsSnarfer(self, irc, msg, match): - r"http://gameknot\.com/stats\.pl\?([^&]+)" + r"http://gameknot\.com/stats\.pl\?([^& ]+)" if not self.registryValue('statSnarfer', msg.args[0]): return name = match.group(1) diff --git a/test/test_Gameknot.py b/test/test_Gameknot.py index 8d121f88a..e2d8ae920 100644 --- a/test/test_Gameknot.py +++ b/test/test_Gameknot.py @@ -61,20 +61,39 @@ if network: conf.supybot.plugins.Gameknot.gameSnarfer.setValue(orig) def testStatsUrlSnarfer(self): - conf.supybot.plugins.Gameknot.statSnarfer.setValue(True) - self.assertNotError('http://gameknot.com/stats.pl?ironchefchess') - self.assertRegexp('http://gameknot.com/stats.pl?ddipaolo&1', - r'^[^&]+$') + orig = conf.supybot.plugins.Gameknot.statSnarfer() + try: + conf.supybot.plugins.Gameknot.statSnarfer.setValue(True) + self.assertSnarfNotError( + 'http://gameknot.com/stats.pl?ironchefchess') + self.assertSnarfRegexp( + 'http://gameknot.com/stats.pl?ddipaolo&1', + r'^[^&]+$') + self.assertSnarfRegexp( + 'http://gameknot.com/stats.pl?ddipaolo and some extra', + r'^ddipaolo is rated') + finally: + conf.supybot.plugins.Gameknot.statSnarfer.setValue(orig) def testConfig(self): - conf.supybot.plugins.Gameknot.gameSnarfer.setValue(False) - conf.supybot.plugins.Gameknot.statSnarfer.setValue(False) - self.assertNoResponse('http://gameknot.com/stats.pl?ironchefchess') - self.assertNoResponse('http://gameknot.com/chess.pl?bd=907498') - conf.supybot.plugins.Gameknot.gameSnarfer.setValue(True) - conf.supybot.plugins.Gameknot.statSnarfer.setValue(True) - self.assertNotError('http://gameknot.com/stats.pl?ironchefchess') - self.assertNotError('http://gameknot.com/chess.pl?bd=907498') + game = conf.supybot.plugins.Gameknot.gameSnarfer() + stat = conf.supybot.plugins.Gameknot.statSnarfer() + try: + conf.supybot.plugins.Gameknot.gameSnarfer.setValue(False) + conf.supybot.plugins.Gameknot.statSnarfer.setValue(False) + self.assertSnarfNoResponse( + 'http://gameknot.com/stats.pl?ironchefchess') + self.assertSnarfNoResponse( + 'http://gameknot.com/chess.pl?bd=907498') + conf.supybot.plugins.Gameknot.gameSnarfer.setValue(True) + conf.supybot.plugins.Gameknot.statSnarfer.setValue(True) + self.assertSnarfNotError( + 'http://gameknot.com/stats.pl?ironchefchess', timeout=20) + self.assertSnarfNotError( + 'http://gameknot.com/chess.pl?bd=907498') + finally: + conf.supybot.plugins.Gameknot.gameSnarfer.setValue(game) + conf.supybot.plugins.Gameknot.statSnarfer.setValue(stat) def testSnarfer(self): @@ -82,15 +101,14 @@ if network: try: conf.supybot.plugins.Gameknot.gameSnarfer.setValue(True) self.assertSnarfRegexp( - 'http://gameknot.com/chess.pl?bd=955432', - '\x02ddipaolo\x02 lost') + 'http://gameknot.com/chess.pl?bd=955432', + '\x02ddipaolo\x02 lost') self.assertSnarfRegexp( - 'http://gameknot.com/chess.pl?bd=1077345&r=365', - 'draw') + 'http://gameknot.com/chess.pl?bd=1077345&r=365', + 'draw') finally: conf.supybot.plugins.Gameknot.gameSnarfer.setValue(orig) - # vim:set shiftwidth=4 tabstop=8 expandtab textwidth=78: