Add handling of 'Invalid Item' pages. Update tests to check 'Invalid Item'

handling and to parse another active .ca page
This commit is contained in:
James Vega 2003-11-09 03:15:24 +00:00
parent 234728b322
commit 4b94ebe146
2 changed files with 11 additions and 2 deletions

View File

@ -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'<title>eBay item (\d+) \([^)]+\) - ([^<]+)</title>',
_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()

View File

@ -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: