@@ -27,15 +27,15 @@ async def sap_code(api: PyaterochkaAPI) -> str:
2727 return resp ["selectedStore" ]["sapCode" ]
2828
2929@pytest .fixture (scope = "session" )
30- async def category_id (api : PyaterochkaAPI , sap_code : str ) -> str :
30+ async def first_category (api : PyaterochkaAPI , sap_code : str ) -> str :
3131 """Фикстура для получения данных категории"""
3232 tree_resp = await api .Catalog .tree (sap_code_store_id = sap_code )
3333 tree_data = tree_resp .json ()
34- return tree_data [0 ][ "id" ]
34+ return tree_data [0 ]
3535
3636@pytest .fixture (scope = "session" )
37- async def product_plu (api : PyaterochkaAPI , sap_code : str , category_id : str ) -> str :
38- resp = await api .Catalog .products_list (category_id = category_id , sap_code_store_id = sap_code )
37+ async def product_plu (api : PyaterochkaAPI , sap_code : str , first_category : dict ) -> str :
38+ resp = await api .Catalog .products_list (category_id = first_category [ "id" ] , sap_code_store_id = sap_code )
3939 data = resp .json ()
4040 return data ["products" ][0 ]["plu" ]
4141
@@ -59,8 +59,8 @@ async def test_tree(sap_code: str, api: PyaterochkaAPI, schemashot: SchemaShot):
5959 data = resp .json ()
6060 schemashot .assert_json_match (data , api .Catalog .tree )
6161
62- async def test_tree_extended (sap_code : str , category_id : str , api : PyaterochkaAPI , schemashot : SchemaShot ):
63- resp = await api .Catalog .tree_extended (sap_code_store_id = sap_code , category_id = category_id )
62+ async def test_tree_extended (sap_code : str , first_category : dict , api : PyaterochkaAPI , schemashot : SchemaShot ):
63+ resp = await api .Catalog .tree_extended (sap_code_store_id = sap_code , category_id = first_category [ "id" ] )
6464 data = resp .json ()
6565 schemashot .assert_json_match (data , api .Catalog .tree_extended )
6666
@@ -69,13 +69,13 @@ async def test_search(sap_code: str, api: PyaterochkaAPI, schemashot: SchemaShot
6969 data = resp .json ()
7070 schemashot .assert_json_match (data , api .Catalog .search )
7171
72- async def test_products_list (sap_code : str , category_id : str , api : PyaterochkaAPI , schemashot : SchemaShot ):
73- resp = await api .Catalog .products_list (category_id = category_id , sap_code_store_id = sap_code )
72+ async def test_products_list (sap_code : str , first_category : dict , api : PyaterochkaAPI , schemashot : SchemaShot ):
73+ resp = await api .Catalog .products_list (category_id = first_category [ "id" ] , sap_code_store_id = sap_code )
7474 data = resp .json ()
7575 schemashot .assert_json_match (data , api .Catalog .products_list )
7676
77- async def test_products_line (sap_code : str , category_id : str , api : PyaterochkaAPI , schemashot : SchemaShot ):
78- resp = await api .Catalog .products_line (category_id = category_id , sap_code_store_id = sap_code )
77+ async def test_products_line (sap_code : str , first_category : dict , api : PyaterochkaAPI , schemashot : SchemaShot ):
78+ resp = await api .Catalog .products_line (category_id = first_category [ "id" ] , sap_code_store_id = sap_code )
7979 data = resp .json ()
8080 schemashot .assert_json_match (data , api .Catalog .products_line )
8181
@@ -109,4 +109,9 @@ async def test_find_store(geoposition: list[float, float], api: PyaterochkaAPI,
109109 data = resp .json ()
110110 schemashot .assert_json_match (data , api .Geolocation .find_store )
111111
112- # TODO download image
112+ async def test_download_image (api : PyaterochkaAPI , first_category : dict ):
113+ resp = await api .General .download_image (first_category ["categories" ][0 ]["image_link" ])
114+
115+ with Image .open (resp ) as img :
116+ fmt = img .format .lower ()
117+ assert fmt in ("png" , "jpeg" , "webp" )
0 commit comments