class AmazonParserTestCase(TestCase): def setUp(self): self.parser = AmazonParser() def test_parse(self): test_url_book = "http://www.amazon.com/Learning-Python-Edition-Mark-Lutz/dp/1449355730/ref=sr_1_1?ie=UTF8&qid=1395302708&sr=8-1&keywords=python" url_obj = urlopen(test_url_book) test_title = "Learning Python, 5th Edition" test_authors = u"Mark Lutz" test_descr = u"Get a comprehensive, in-depth introduction to the core Python language with this hands-on book." test_picture_url = "http://ecx.images-amazon.com/images/I/517JerW0%2B3L._SL160_.jpg" book = self.parser.parse(url_obj) self.assertEqual(test_title, book["title"]) self.assertEqual(test_authors, book["authors"]) self.assertIsNotNone(search("^([0-9]+\.[0-9]+\s\w+)$", book["price"])) self.assertTrue(test_descr in book["description"]) self.assertEqual(test_picture_url, book["book_image_url"])
def setUp(self): self.parser = AmazonParser()