Exemplo n.º 1
0
 def test_see_all_reviews(self):
     amazon_spider = AmazonSpider()
     response = TextResponse(url="", encoding="utf8")
     response._set_body("<a href=\"/pass\">all revs See now </a>")
     result = next(amazon_spider.see_all_reviews(response))
     #self.assertIs(result, generator)
     self.assertIsInstance(result, Request)
     self.assertEqual(result.url, amazon_spider.base_url + "/pass")
Exemplo n.º 2
0
 def test_extract_next_pagination(self):
     amazon_spider = AmazonSpider()
     i = 0
     for data, result in td.pagination.items():
         #TODO : unless the response is instantiated every time, it caches old data
         response = TextResponse(url="", encoding="utf8")
         response._set_body(data)
         with self.subTest():
             self.assertEqual(
                 amazon_spider.extract_next_pagination(response), result,
                 "data index {}".format(i))
         i = i + 1