From e1c0b89e918f3dc4fba9880680891c185c2bae82 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adri=C3=A1n=20Chaves?= Date: Thu, 15 Feb 2024 15:13:49 +0100 Subject: [PATCH] Apply naming suggested by Kevin --- tests/test_ecommerce.py | 10 +++++----- zyte_spider_templates/spiders/ecommerce.py | 8 ++++---- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/tests/test_ecommerce.py b/tests/test_ecommerce.py index 58b11fb..d0baec0 100644 --- a/tests/test_ecommerce.py +++ b/tests/test_ecommerce.py @@ -214,12 +214,12 @@ def test_crawl(): assert request.callback == spider.parse_navigation -def test_crawl_strategy_none(): +def test_crawl_strategy_direct_product(): crawler = get_crawler() spider = EcommerceSpider.from_crawler( crawler, url="https://example.com", - crawl_strategy="none", + crawl_strategy="direct_product", ) start_requests = list(spider.start_requests()) assert len(start_requests) == 1 @@ -372,7 +372,7 @@ def test_metadata(): "title": "Crawl strategy", "description": "Determines how the start URL and follow-up URLs are crawled.", "type": "string", - "enum": ["full", "navigation", "pagination_only", "none"], + "enum": ["full", "navigation", "pagination_only", "direct_product"], "enumMeta": { "full": { "description": "Follow most links within the domain of URL in an attempt to discover and extract as many products as possible.", @@ -389,12 +389,12 @@ def test_metadata(): ), "title": "Pagination Only", }, - "none": { + "direct_product": { "description": ( "Treat input URLs as direct links to product detail pages, and " "extract a product from each." ), - "title": "None", + "title": "Direct URLs to Product", }, }, }, diff --git a/zyte_spider_templates/spiders/ecommerce.py b/zyte_spider_templates/spiders/ecommerce.py index d6f0493..23b31a4 100644 --- a/zyte_spider_templates/spiders/ecommerce.py +++ b/zyte_spider_templates/spiders/ecommerce.py @@ -32,7 +32,7 @@ class EcommerceCrawlStrategy(str, Enum): ignored. Use this when some subCategory links are misidentified by ML-extraction.""" - none: str = "none" + direct_product: str = "direct_product" """Treat input URLs as direct links to product detail pages, and extract a product from each.""" @@ -59,8 +59,8 @@ class EcommerceSpiderParams(BaseSpiderParams): "Use this when some subCategory links are misidentified by ML-extraction." ), }, - EcommerceCrawlStrategy.none: { - "title": "None", + EcommerceCrawlStrategy.direct_product: { + "title": "Direct URLs to Product", "description": ( "Treat input URLs as direct links to product detail pages, and " "extract a product from each." @@ -126,7 +126,7 @@ def from_crawler(cls, crawler: Crawler, *args, **kwargs) -> scrapy.Spider: def start_requests(self) -> Iterable[Request]: callback = ( self.parse_product - if self.args.crawl_strategy == EcommerceCrawlStrategy.none + if self.args.crawl_strategy == EcommerceCrawlStrategy.direct_product else self.parse_navigation ) page_params = {}