From 4b94ebe146d6a90c659dee7150ab64024a5681cf Mon Sep 17 00:00:00 2001 From: James Vega Date: Sun, 9 Nov 2003 03:15:24 +0000 Subject: [PATCH] Add handling of 'Invalid Item' pages. Update tests to check 'Invalid Item' handling and to parse another active .ca page --- plugins/Ebay.py | 8 ++++++++ test/test_Ebay.py | 5 +++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/plugins/Ebay.py b/plugins/Ebay.py index 419c9023a..cd1571230 100644 --- a/plugins/Ebay.py +++ b/plugins/Ebay.py @@ -80,6 +80,8 @@ class Ebay(callbacks.PrivmsgCommandAndRegexp, plugins.Configurable): callbacks.PrivmsgCommandAndRegexp.__init__(self) _reopts = re.I | re.S + _invalid = re.compile(r'(is invalid, still pending, or no longer in our '\ + 'database)', _reopts) _info = re.compile(r'eBay item (\d+) \([^)]+\) - ([^<]+)', _reopts) @@ -134,6 +136,12 @@ class Ebay(callbacks.PrivmsgCommandAndRegexp, plugins.Configurable): s = fd.read() fd.close() resp = [] + m = self._invalid.search(s) + if m: + if snarf: + return + irc.reply(msg, 'That auction %s' % m.group(1)) + return m = self._info.search(s) if m: (num, desc) = m.groups() diff --git a/test/test_Ebay.py b/test/test_Ebay.py index a066ac4cc..178a368bd 100644 --- a/test/test_Ebay.py +++ b/test/test_Ebay.py @@ -36,6 +36,8 @@ class EbayTest(PluginTestCase, PluginDocumentation): def testEbay(self): self.assertResponse('ebay --link 3053641570', 'http://cgi.ebay.com/ws/eBayISAPI.dll?ViewItem&item=3053641570') + # test 'Invalid Item' checking + self.assertRegexp('ebay 2357056673', 'That auction is invalid') def testSnarfer(self): self.assertRegexp('http://cgi.ebay.com/ws/eBayISAPI.dll?ViewItem' @@ -46,7 +48,7 @@ class EbayTest(PluginTestCase, PluginDocumentation): 'RESERVE.*izontech \(.*') # test snarfing other countries self.assertRegexp('http://cgi.ebay.ca/ws/eBayISAPI.dll?ViewItem&' - 'item=2357056673', 'Buffalo Pemmican') + 'item=3636820075', 'NEW 34" Itech 8.8 Profile') self.assertRegexp('http://cgi.ebay.co.uk/ws/eBayISAPI.dll?ViewItem&' 'item=2355464443', 'Any Clear Crazy') self.assertRegexp('http://cgi.ebay.com.au/ws/eBayISAPI.dll?ViewItem&' @@ -55,5 +57,4 @@ class EbayTest(PluginTestCase, PluginDocumentation): self.assertRegexp('http://cgi.ebay.com/ebaymotors/ws/eBayISAPI.dll?' 'ViewItem&item=2439393310&category=33708', '88-89 CRX amber') - # vim:set shiftwidth=4 tabstop=8 expandtab textwidth=78: