pyaterochka-api 0.1.6__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- pyaterochka_api/__init__.py +3 -0
- pyaterochka_api/api.py +251 -0
- pyaterochka_api/manager.py +232 -0
- pyaterochka_api-0.1.6.dist-info/METADATA +141 -0
- pyaterochka_api-0.1.6.dist-info/RECORD +12 -0
- pyaterochka_api-0.1.6.dist-info/WHEEL +5 -0
- pyaterochka_api-0.1.6.dist-info/licenses/LICENSE +21 -0
- pyaterochka_api-0.1.6.dist-info/top_level.txt +2 -0
- tests/__init__.py +0 -0
- tests/base_tests.py +66 -0
- tests/snapshots/__init__.py +0 -0
- tests/snapshots/snap_base_tests.py +813 -0
tests/base_tests.py
ADDED
@@ -0,0 +1,66 @@
|
|
1
|
+
import pytest
|
2
|
+
from pyaterochka_api import Pyaterochka
|
3
|
+
from io import BytesIO
|
4
|
+
from snapshottest.pytest import SnapshotTest
|
5
|
+
|
6
|
+
def gen_schema(data):
|
7
|
+
"""Генерирует схему (типы данных вместо значений)."""
|
8
|
+
if isinstance(data, dict):
|
9
|
+
return {k: gen_schema(v) for k, v in data.items()}
|
10
|
+
elif isinstance(data, list):
|
11
|
+
return [gen_schema(data[0])] if data else []
|
12
|
+
else:
|
13
|
+
return type(data).__name__
|
14
|
+
|
15
|
+
@pytest.mark.asyncio
|
16
|
+
async def test_list(snapshot: SnapshotTest):
|
17
|
+
async with Pyaterochka() as API:
|
18
|
+
categories = await API.categories_list(subcategories=True)
|
19
|
+
snapshot.assert_match(gen_schema(categories), "categories_list")
|
20
|
+
|
21
|
+
result = await API.products_list(category_id=categories[0]['id'], limit=5)
|
22
|
+
snapshot.assert_match(gen_schema(result), "products_list")
|
23
|
+
|
24
|
+
@pytest.mark.asyncio
|
25
|
+
async def test_product_info(snapshot: SnapshotTest):
|
26
|
+
async with Pyaterochka() as API:
|
27
|
+
result = await API.product_info(43347)
|
28
|
+
snapshot.assert_match(gen_schema(result), "product_info")
|
29
|
+
|
30
|
+
@pytest.mark.asyncio
|
31
|
+
async def test_get_news(snapshot: SnapshotTest):
|
32
|
+
async with Pyaterochka() as API:
|
33
|
+
result = await API.get_news(limit=5)
|
34
|
+
snapshot.assert_match(gen_schema(result), "get_news")
|
35
|
+
|
36
|
+
@pytest.mark.asyncio
|
37
|
+
async def test_find_store(snapshot: SnapshotTest):
|
38
|
+
async with Pyaterochka() as API:
|
39
|
+
categories = await API.find_store(longitude=37.63156, latitude=55.73768)
|
40
|
+
snapshot.assert_match(gen_schema(categories), "store_info")
|
41
|
+
|
42
|
+
@pytest.mark.asyncio
|
43
|
+
async def test_download_image(snapshot: SnapshotTest):
|
44
|
+
async with Pyaterochka() as API:
|
45
|
+
result = await API.download_image("https://photos.okolo.app/product/1392827-main/800x800.jpeg")
|
46
|
+
assert isinstance(result, BytesIO)
|
47
|
+
assert result.getvalue()
|
48
|
+
snapshot.assert_match("image downloaded", "download_image")
|
49
|
+
|
50
|
+
@pytest.mark.asyncio
|
51
|
+
async def test_set_debug(snapshot: SnapshotTest):
|
52
|
+
async with Pyaterochka(debug=True) as API:
|
53
|
+
API.debug = False
|
54
|
+
snapshot.assert_match(API.debug, "set_debug")
|
55
|
+
|
56
|
+
@pytest.mark.asyncio
|
57
|
+
async def test_rebuild_connection(snapshot: SnapshotTest):
|
58
|
+
async with Pyaterochka() as API:
|
59
|
+
await API.rebuild_connection()
|
60
|
+
snapshot.assert_match("connection has been rebuilt", "rebuild_connection")
|
61
|
+
|
62
|
+
@pytest.mark.asyncio
|
63
|
+
async def test_get_config(snapshot: SnapshotTest):
|
64
|
+
async with Pyaterochka() as API:
|
65
|
+
result = await API.get_config()
|
66
|
+
snapshot.assert_match(gen_schema(result), "get_config")
|
File without changes
|