-
Notifications
You must be signed in to change notification settings - Fork 0
/
amazon_test.py
47 lines (34 loc) · 1.6 KB
/
amazon_test.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
import unittest
from scrapy.crawler import CrawlerProcess
from scrapy.utils.project import get_project_settings
from default.spiders.amazon import AmazonSpider
from dotenv import load_dotenv
from default.spiders.amazon_search import AmazonSearchSpider
from default.spiders.amazon_get_details import AmazonGetDetailsSpider
load_dotenv()
class AmazonSpiderTest(unittest.TestCase):
def setUp(self):
self.crawler_process = CrawlerProcess(get_project_settings())
def test_spider(self):
self.crawler_process.crawl(AmazonSpider,
url='https://www.amazon.com/dp/B0CRDDWTX3',
job_id='123')
self.crawler_process.start()
class AmazonSearchSpiderTest(unittest.TestCase):
def setUp(self):
self.crawler_process = CrawlerProcess(get_project_settings())
def test_spider(self):
self.crawler_process.crawl(AmazonSearchSpider,
url='https://www.amazon.com/s?k=fish%20bowl%20for%20a%20gold%20fish%20made%20of%20glass',
job_id='123')
self.crawler_process.start()
class AmazonGetDetailSpider(unittest.TestCase):
def setUp(self):
self.crawler_process = CrawlerProcess(get_project_settings())
def test_spider(self):
self.crawler_process.crawl(AmazonGetDetailsSpider,
url=['https://www.amazon.com/dp/B0CRDDWTX3', 'https://www.amazon.com/dp/B09LYHV61V'],
job_id='123')
self.crawler_process.start()
if __name__ == '__main__':
unittest.main()