2003-09-06 20:29:35 +02:00
|
|
|
#!/usr/bin/env python
|
|
|
|
|
|
|
|
###
|
2004-08-23 15:14:06 +02:00
|
|
|
# Copyright (c) 2002-2004, Jeremiah Fincher
|
2003-09-06 20:29:35 +02:00
|
|
|
# All rights reserved.
|
|
|
|
#
|
|
|
|
# Redistribution and use in source and binary forms, with or without
|
|
|
|
# modification, are permitted provided that the following conditions are met:
|
|
|
|
#
|
|
|
|
# * Redistributions of source code must retain the above copyright notice,
|
|
|
|
# this list of conditions, and the following disclaimer.
|
|
|
|
# * Redistributions in binary form must reproduce the above copyright notice,
|
|
|
|
# this list of conditions, and the following disclaimer in the
|
|
|
|
# documentation and/or other materials provided with the distribution.
|
|
|
|
# * Neither the name of the author of this software nor the name of
|
|
|
|
# contributors to this software may be used to endorse or promote products
|
|
|
|
# derived from this software without specific prior written consent.
|
|
|
|
#
|
|
|
|
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
|
|
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
|
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
|
|
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
|
|
|
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
|
|
|
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
|
|
|
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
|
|
|
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
|
|
|
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
|
|
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
|
|
# POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
###
|
|
|
|
|
2003-12-02 13:27:45 +01:00
|
|
|
from testsupport import *
|
2003-09-06 20:29:35 +02:00
|
|
|
|
2004-01-20 07:27:17 +01:00
|
|
|
LICENSE_KEY = 'AMAZONS_NOT_CHECKING_KEYS'
|
2003-12-09 02:09:16 +01:00
|
|
|
|
2004-01-01 20:51:48 +01:00
|
|
|
if LICENSE_KEY != 'INITIAL_NON_LICENSE_KEY' and network:
|
2004-02-19 08:40:57 +01:00
|
|
|
class AmazonTestCase(PluginTestCase):
|
2003-12-09 02:09:16 +01:00
|
|
|
plugins = ('Amazon',)
|
|
|
|
def setUp(self):
|
|
|
|
PluginTestCase.setUp(self)
|
2004-01-20 07:27:17 +01:00
|
|
|
conf.supybot.plugins.amazon.licensekey.set(LICENSE_KEY)
|
2003-12-09 02:09:16 +01:00
|
|
|
|
|
|
|
def testIsbn(self):
|
|
|
|
self.assertHelp('isbn')
|
|
|
|
self.assertRegexp('isbn 0738203793',
|
|
|
|
r'Buckminster Fuller\'s Universe')
|
|
|
|
self.assertRegexp('isbn --url 0738203793',
|
|
|
|
r'Buck.*/exec/obidos/ASIN')
|
|
|
|
|
|
|
|
def testAsin(self):
|
|
|
|
self.assertHelp('asin')
|
|
|
|
self.assertRegexp('asin B00005JM5E', r'Pirates of the Caribbean')
|
|
|
|
self.assertRegexp('asin --url B00005JM5E',
|
|
|
|
r'Pirate.*ASIN/B00005JM5E')
|
|
|
|
|
|
|
|
def testUpc(self):
|
|
|
|
self.assertHelp('upc')
|
|
|
|
self.assertRegexp('upc 093624586425', r'Short Bus')
|
|
|
|
self.assertRegexp('upc --url 093624586425',
|
|
|
|
r'Short Bus.*/exec/obidos')
|
|
|
|
|
|
|
|
def testAuthor(self):
|
2004-08-01 16:38:37 +02:00
|
|
|
self.assertHelp('amazon author')
|
2004-08-11 14:33:25 +02:00
|
|
|
self.assertNotError('amazon author torvalds')
|
|
|
|
self.assertNotError('amazon author --url torvalds')
|
2003-12-09 02:09:16 +01:00
|
|
|
|
|
|
|
def testArtist(self):
|
|
|
|
self.assertHelp('artist')
|
2004-08-11 14:33:25 +02:00
|
|
|
self.assertNotError('artist rahzel')
|
|
|
|
self.assertNotError('artist --url rahzel')
|
|
|
|
self.assertError('artist --classical rahzel')
|
|
|
|
self.assertNotError('artist --classical vivaldi')
|
2003-12-09 02:09:16 +01:00
|
|
|
|
|
|
|
def testActor(self):
|
|
|
|
self.assertHelp('actor')
|
2004-08-11 14:33:25 +02:00
|
|
|
self.assertNotError('actor bruce lee')
|
|
|
|
self.assertNotError('actor --url bruce lee')
|
|
|
|
self.assertNotError('actor --vhs bruce lee')
|
|
|
|
self.assertNotError('actor --video bruce lee')
|
2003-12-09 02:09:16 +01:00
|
|
|
|
|
|
|
def testDirector(self):
|
|
|
|
self.assertHelp('director')
|
2004-08-11 14:33:25 +02:00
|
|
|
self.assertNotError('director gore verbinski')
|
|
|
|
self.assertNotError('director --url gore verbinski')
|
|
|
|
self.assertNotError('director --vhs gore verbinski')
|
|
|
|
self.assertNotError('director --video gore verbinski')
|
2003-12-09 02:09:16 +01:00
|
|
|
|
|
|
|
def testManufacturer(self):
|
|
|
|
self.assertHelp('manufacturer')
|
2004-08-11 14:33:25 +02:00
|
|
|
self.assertNotError('manufacturer iomega')
|
|
|
|
self.assertNotError('manufacturer --url iomega')
|
|
|
|
self.assertNotError('manufacturer --electronics plextor')
|
|
|
|
self.assertNotError('manufacturer --kitchen henckels')
|
|
|
|
self.assertNotError('manufacturer --videogames ea')
|
|
|
|
self.assertNotError('manufacturer --software adobe')
|
|
|
|
self.assertNotError('manufacturer --photo kodak')
|
2003-12-09 02:09:16 +01:00
|
|
|
|
|
|
|
def testBooks(self):
|
|
|
|
self.assertHelp('books')
|
2004-08-11 14:33:25 +02:00
|
|
|
self.assertNotError('books knowledge of the holy')
|
2003-12-09 02:09:16 +01:00
|
|
|
|
|
|
|
def testVideos(self):
|
|
|
|
self.assertHelp('videos')
|
2004-08-11 14:33:25 +02:00
|
|
|
self.assertNotError('videos zim')
|
|
|
|
self.assertNotError('videos --vhs samuel jackson')
|
2003-12-08 17:32:29 +01:00
|
|
|
|
2004-02-17 17:40:32 +01:00
|
|
|
def testSnarfer(self):
|
|
|
|
try:
|
|
|
|
orig = conf.supybot.plugins.Amazon.linkSnarfer()
|
|
|
|
conf.supybot.plugins.Amazon.linkSnarfer.setValue(True)
|
|
|
|
self.assertRegexp('http://www.amazon.com/exec/obidos/tg/'
|
|
|
|
'detail/-/B0001CSI3S/sr=1-2/qid=1076951698'
|
|
|
|
'/ref=sr_1_2/002-0542016-6528044?v=glance&'
|
|
|
|
'n=1044448&s=apparel',
|
|
|
|
r'.*Spring Parka.*')
|
|
|
|
finally:
|
|
|
|
conf.supybot.plugins.Amazon.linkSnarfer.setValue(orig)
|
|
|
|
self.assertNoResponse('http://www.amazon.com/exec/obidos/tg/detail'
|
|
|
|
'/-/B0001CSI3S/sr=1-2/qid=1076951698/ref='
|
|
|
|
'sr_1_2/002-0542016-6528044?v=glance&n='
|
|
|
|
'1044448&s=apparel')
|
|
|
|
|
2003-09-06 20:29:35 +02:00
|
|
|
# vim:set shiftwidth=4 tabstop=8 expandtab textwidth=78:
|
|
|
|
|