11from typing import Any
22
33import pytest
4- from human_requests import autotest_depends_on , autotest_hook , autotest_params , autotest_data
5- from human_requests .autotest import AutotestCallContext , AutotestContext ,AutotestDataContext
6-
4+ from human_requests import (
5+ autotest_data ,
6+ autotest_depends_on ,
7+ autotest_hook ,
8+ autotest_params ,
9+ )
10+ from human_requests .autotest import (
11+ AutotestCallContext ,
12+ AutotestContext ,
13+ AutotestDataContext ,
14+ )
715from PIL import Image
816
917from chizhik_api import ChizhikAPI
@@ -69,25 +77,32 @@ def _capture_first_store_id(
6977def _delivery_tree (ctx : AutotestContext ):
7078 return {"store_id" : ctx .state ["autotest_store_id" ]}
7179
80+
7281@autotest_depends_on (ShopService .search )
7382@autotest_depends_on (ClassCatalog .delivery_tree )
7483@autotest_params (target = ClassCatalog .delivery_tree_extended )
7584def _delivery_tree_extended (ctx : AutotestContext ):
76- return {"store_id" : ctx .state ["autotest_store_id" ],
77- "category_alias" : ctx .state .get ("autotest_category_alias" )}
85+ return {
86+ "store_id" : ctx .state ["autotest_store_id" ],
87+ "category_alias" : ctx .state .get ("autotest_category_alias" ),
88+ }
89+
7890
7991@autotest_depends_on (ShopService .search )
8092@autotest_depends_on (ClassCatalog .delivery_tree )
8193@autotest_params (target = ClassCatalog .delivery_products_list )
8294def _delivery_products_list (ctx : AutotestContext ):
83- return {"store_id" : ctx .state ["autotest_store_id" ],
84- "category_alias" : ctx .state .get ("autotest_category_alias" )}
95+ return {
96+ "store_id" : ctx .state ["autotest_store_id" ],
97+ "category_alias" : ctx .state .get ("autotest_category_alias" ),
98+ }
99+
85100
86101@autotest_depends_on (ShopService .search )
87102@autotest_params (target = ClassCatalog .delivery_search )
88103def _delivery_search (ctx : AutotestContext ):
89- return {"store_id" : ctx .state ["autotest_store_id" ],
90- "query" : "кола" }
104+ return {"store_id" : ctx .state ["autotest_store_id" ], "query" : "кола" }
105+
91106
92107@autotest_hook (target = ClassCatalog .delivery_products_list )
93108def _capture_first_plu (
@@ -100,15 +115,21 @@ def _capture_first_plu(
100115
101116 store_id = data .get ("products" )
102117 if not isinstance (store_id , list ):
103- pytest .fail ("ClassCatalog.delivery_products_list did not return a valid category id." )
118+ pytest .fail (
119+ "ClassCatalog.delivery_products_list did not return a valid category id."
120+ )
104121
105122 ctx .state ["autotest_plu" ] = store_id [0 ]["plu" ]
106123
124+
107125@autotest_depends_on (ClassCatalog .delivery_tree )
108126@autotest_params (target = ProductService .delivery_info )
109127def _delivery_info (ctx : AutotestContext ):
110- return {"store_id" : ctx .state ["autotest_store_id" ],
111- "product_id" : ctx .state .get ("autotest_plu" )}
128+ return {
129+ "store_id" : ctx .state ["autotest_store_id" ],
130+ "product_id" : ctx .state .get ("autotest_plu" ),
131+ }
132+
112133
113134@autotest_hook (target = ClassCatalog .delivery_tree_extended )
114135def _capture_first_subcategory_alias (
@@ -125,12 +146,16 @@ def _capture_first_subcategory_alias(
125146
126147 ctx .state ["autotest_subcategory_alias" ] = store_id [0 ]["id" ]
127148
149+
128150@autotest_depends_on (ShopService .search )
129151@autotest_depends_on (ClassCatalog .delivery_tree_extended )
130152@autotest_params (target = ClassCatalog .delivery_tree_ancestors )
131153def _delivery_tree_ancestors (ctx : AutotestContext ):
132- return {"store_id" : ctx .state ["autotest_store_id" ],
133- "category_alias" : ctx .state .get ("autotest_subcategory_alias" )}
154+ return {
155+ "store_id" : ctx .state ["autotest_store_id" ],
156+ "category_alias" : ctx .state .get ("autotest_subcategory_alias" ),
157+ }
158+
134159
135160@autotest_depends_on (ClassCatalog .tree )
136161@autotest_params (target = ClassCatalog .products_list )
@@ -189,11 +214,11 @@ def _product_info_params(ctx: AutotestCallContext) -> dict[str, int]:
189214 pytest .fail ("ProductService.info depends on Catalog.products_list." )
190215
191216
192-
193217@autotest_data (name = "unstandard_headers" )
194218def _unstandard_headers_data (ctx : AutotestDataContext ) -> dict [str , Any ]:
195219 return ctx .api .unstandard_headers
196220
221+
197222@autotest_data (name = "unstandard_urls" )
198223def _unstandard_urls_data (ctx : AutotestDataContext ) -> dict [str , Any ]:
199224 return ctx .api .unstandard_urls
0 commit comments