pyaterochka-api 0.1.7__py3-none-any.whl → 0.1.9__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 +2 -1
- pyaterochka_api/api.py +47 -146
- pyaterochka_api/enums.py +14 -0
- pyaterochka_api/manager.py +42 -40
- pyaterochka_api/tools.py +121 -0
- {pyaterochka_api-0.1.7.dist-info → pyaterochka_api-0.1.9.dist-info}/METADATA +10 -3
- pyaterochka_api-0.1.9.dist-info/RECORD +13 -0
- {pyaterochka_api-0.1.7.dist-info → pyaterochka_api-0.1.9.dist-info}/WHEEL +1 -1
- tests/{base_tests.py → api_tests.py} +16 -25
- tests/tools_tests.py +30 -0
- pyaterochka_api-0.1.7.dist-info/RECORD +0 -12
- tests/snapshots/__init__.py +0 -0
- tests/snapshots/snap_base_tests.py +0 -813
- {pyaterochka_api-0.1.7.dist-info → pyaterochka_api-0.1.9.dist-info}/licenses/LICENSE +0 -0
- {pyaterochka_api-0.1.7.dist-info → pyaterochka_api-0.1.9.dist-info}/top_level.txt +0 -0
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: pyaterochka_api
|
3
|
-
Version: 0.1.
|
3
|
+
Version: 0.1.9
|
4
4
|
Summary: A Python API client for Pyaterochka store catalog
|
5
5
|
Home-page: https://github.com/Open-Inflation/pyaterochka_api
|
6
6
|
Author: Miskler
|
@@ -28,7 +28,7 @@ Requires-Dist: tqdm
|
|
28
28
|
Provides-Extra: tests
|
29
29
|
Requires-Dist: pytest; extra == "tests"
|
30
30
|
Requires-Dist: pytest-asyncio; extra == "tests"
|
31
|
-
Requires-Dist:
|
31
|
+
Requires-Dist: pytest-typed-schema-shot; extra == "tests"
|
32
32
|
Dynamic: author
|
33
33
|
Dynamic: classifier
|
34
34
|
Dynamic: description
|
@@ -48,6 +48,7 @@ Pyaterochka (Пятёрочка) - https://5ka.ru/
|
|
48
48
|

|
49
49
|

|
50
50
|
[](https://pypi.org/project/pyaterochka-api/)
|
51
|
+
[](https://open-inflation.github.io/pyaterochka_api/)
|
51
52
|
[](https://discord.gg/UnJnGHNbBp)
|
52
53
|
[](https://t.me/miskler_dev)
|
53
54
|
|
@@ -69,7 +70,7 @@ camoufox fetch
|
|
69
70
|
|
70
71
|
### Usage / Использование:
|
71
72
|
```py
|
72
|
-
from pyaterochka_api import Pyaterochka
|
73
|
+
from pyaterochka_api import Pyaterochka, PurchaseMode
|
73
74
|
import asyncio
|
74
75
|
|
75
76
|
|
@@ -146,6 +147,12 @@ if __name__ == '__main__':
|
|
146
147
|
asyncio.run(main())
|
147
148
|
```
|
148
149
|
|
150
|
+
### API Documentation / Документация API
|
151
|
+
|
152
|
+
Автоматически сгенерированная документация API доступна по ссылке: [API Documentation](https://open-inflation.github.io/pyaterochka_api/)
|
153
|
+
|
154
|
+
Документация содержит подробную структуру всех ответов сервера в виде схем (на базе тестов).
|
155
|
+
|
149
156
|
### Report / Обратная связь
|
150
157
|
|
151
158
|
If you have any problems using it /suggestions, do not hesitate to write to the [project's GitHub](https://github.com/Open-Inflation/pyaterochka_api/issues)!
|
@@ -0,0 +1,13 @@
|
|
1
|
+
pyaterochka_api/__init__.py,sha256=6XnalFPUumYqDJFyXw2puejJ612o-D1tYjZ_IjQ7Hx0,108
|
2
|
+
pyaterochka_api/api.py,sha256=KEr28n1aH69cVo0ztHCgB4ANVVZ-CezLWYTiPpfAmoc,7793
|
3
|
+
pyaterochka_api/enums.py,sha256=JnX4JiHzXyRo4se8sCFx0LyqcKlXXED0VcA0xI7r_ZI,621
|
4
|
+
pyaterochka_api/manager.py,sha256=yQw0njGCsropysT-_siuyNxXNpX-VJKOcVD8b-aV48I,10765
|
5
|
+
pyaterochka_api/tools.py,sha256=xFOThNRClX4u0cMfmQ5fVQKLM2Fn-rBAekzo_yBvRnQ,4447
|
6
|
+
pyaterochka_api-0.1.9.dist-info/licenses/LICENSE,sha256=Ee_P5XQUYoJuffzRL24j4GWpqgoWphUOKswpB2f9HcQ,1071
|
7
|
+
tests/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
8
|
+
tests/api_tests.py,sha256=Sx2tAVGLbubpzJOn166ECJj64oYUv1S6c5fYfGLGvu0,2227
|
9
|
+
tests/tools_tests.py,sha256=UKWVHu-QkEzc7iLsm5wIhA17FLq3E7SxwkLHc5GEI2M,1040
|
10
|
+
pyaterochka_api-0.1.9.dist-info/METADATA,sha256=nUC4TfS_mT1VQ2MZLKNpLM4YF1ZfvaZ33bqOHhimHZk,9855
|
11
|
+
pyaterochka_api-0.1.9.dist-info/WHEEL,sha256=zaaOINJESkSfm_4HQVc5ssNzHCPXhJm0kEUakpsEHaU,91
|
12
|
+
pyaterochka_api-0.1.9.dist-info/top_level.txt,sha256=PXTSi8y2C5_Mz20pJJFqOUBnjAIAXP_cc38mthvJ2x4,22
|
13
|
+
pyaterochka_api-0.1.9.dist-info/RECORD,,
|
@@ -1,63 +1,54 @@
|
|
1
1
|
import pytest
|
2
2
|
from pyaterochka_api import Pyaterochka
|
3
3
|
from io import BytesIO
|
4
|
-
from
|
4
|
+
from typed_schema_shot import SchemaShot
|
5
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
6
|
|
15
7
|
@pytest.mark.asyncio
|
16
|
-
async def test_list(
|
8
|
+
async def test_list(schemashot: SchemaShot):
|
17
9
|
async with Pyaterochka(debug=True, trust_env=True) as API:
|
18
10
|
categories = await API.categories_list(subcategories=True)
|
19
|
-
|
20
|
-
|
11
|
+
schemashot.assert_match(categories, "categories_list")
|
12
|
+
|
21
13
|
result = await API.products_list(category_id=categories[0]['id'], limit=5)
|
22
|
-
|
14
|
+
schemashot.assert_match(result, "products_list")
|
23
15
|
|
24
16
|
@pytest.mark.asyncio
|
25
|
-
async def test_product_info(
|
17
|
+
async def test_product_info(schemashot: SchemaShot):
|
26
18
|
async with Pyaterochka(trust_env=True) as API:
|
27
19
|
result = await API.product_info(43347)
|
28
|
-
|
20
|
+
schemashot.assert_match(result, "product_info")
|
29
21
|
|
30
22
|
@pytest.mark.asyncio
|
31
|
-
async def test_get_news(
|
23
|
+
async def test_get_news(schemashot: SchemaShot):
|
32
24
|
async with Pyaterochka(debug=True, trust_env=True) as API:
|
33
25
|
result = await API.get_news(limit=5)
|
34
|
-
|
26
|
+
schemashot.assert_match(result, "get_news")
|
35
27
|
|
36
28
|
@pytest.mark.asyncio
|
37
|
-
async def test_find_store(
|
29
|
+
async def test_find_store(schemashot: SchemaShot):
|
38
30
|
async with Pyaterochka(debug=True, trust_env=True) as API:
|
39
31
|
categories = await API.find_store(longitude=37.63156, latitude=55.73768)
|
40
|
-
|
32
|
+
schemashot.assert_match(categories, "store_info")
|
41
33
|
|
42
34
|
@pytest.mark.asyncio
|
43
|
-
async def test_download_image(
|
35
|
+
async def test_download_image(schemashot: SchemaShot):
|
44
36
|
async with Pyaterochka(debug=True, trust_env=True) as API:
|
45
37
|
result = await API.download_image("https://photos.okolo.app/product/1392827-main/800x800.jpeg")
|
46
38
|
assert isinstance(result, BytesIO)
|
47
39
|
assert result.getvalue()
|
48
|
-
snapshot.assert_match("image downloaded", "download_image")
|
49
40
|
|
50
41
|
@pytest.mark.asyncio
|
51
|
-
async def test_set_debug(
|
42
|
+
async def test_set_debug(schemashot: SchemaShot):
|
52
43
|
async with Pyaterochka(debug=True) as API:
|
44
|
+
assert API.debug == True
|
53
45
|
API.debug = False
|
54
|
-
|
46
|
+
assert API.debug == False
|
55
47
|
|
56
48
|
@pytest.mark.asyncio
|
57
|
-
async def test_rebuild_connection(
|
49
|
+
async def test_rebuild_connection(schemashot: SchemaShot):
|
58
50
|
async with Pyaterochka(debug=True, trust_env=True) as API:
|
59
51
|
await API.rebuild_connection()
|
60
|
-
snapshot.assert_match("connection has been rebuilt", "rebuild_connection")
|
61
52
|
|
62
53
|
#@pytest.mark.asyncio
|
63
54
|
#async def test_get_config(snapshot: SnapshotTest):
|
tests/tools_tests.py
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
import pytest
|
2
|
+
from pyaterochka_api.tools import parse_proxy
|
3
|
+
import itertools
|
4
|
+
import logging
|
5
|
+
|
6
|
+
@pytest.mark.asyncio
|
7
|
+
async def test_parse_proxy():
|
8
|
+
# Варианты параметров
|
9
|
+
schemes = ['http://', 'https://', '']
|
10
|
+
auths = [('', ''), ('user', 'pass')]
|
11
|
+
hosts = ['127.0.0.1', 'example.com']
|
12
|
+
ports = ['', '8080']
|
13
|
+
|
14
|
+
logger = logging.getLogger("test_parse_proxy")
|
15
|
+
|
16
|
+
for scheme, (username, password), host, port in itertools.product(schemes, auths, hosts, ports):
|
17
|
+
# Формируем строку прокси
|
18
|
+
auth_part = f"{username}:{password}@" if username else ""
|
19
|
+
port_part = f":{port}" if port else ""
|
20
|
+
proxy_str = f"{scheme}{auth_part}{host}{port_part}"
|
21
|
+
|
22
|
+
expected = {'server': f"{scheme}{host}{port_part}"}
|
23
|
+
if not scheme:
|
24
|
+
expected['server'] = "http://"+expected['server']
|
25
|
+
if username:
|
26
|
+
expected['username'] = username
|
27
|
+
expected['password'] = password
|
28
|
+
|
29
|
+
assert parse_proxy(proxy_str, True, logger) == expected
|
30
|
+
|
@@ -1,12 +0,0 @@
|
|
1
|
-
pyaterochka_api/__init__.py,sha256=s91K-ZPzFZkk93AY_BtXwhpSxZpO1IHi1a3RThd1jtM,60
|
2
|
-
pyaterochka_api/api.py,sha256=sE6AqTwdGvVcdW1BSZfPiRV_NIgBQs1f_t84iqVY_s8,11188
|
3
|
-
pyaterochka_api/manager.py,sha256=8uTV9Cia0arrNc-dnOPG7dl9REU7QFzisysT7Krih7E,10733
|
4
|
-
pyaterochka_api-0.1.7.dist-info/licenses/LICENSE,sha256=Ee_P5XQUYoJuffzRL24j4GWpqgoWphUOKswpB2f9HcQ,1071
|
5
|
-
tests/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
6
|
-
tests/base_tests.py,sha256=XgOFu8yUKYqeRZ6QuQE-ZjMuPreQUb9y8iR7bDw-DOE,2763
|
7
|
-
tests/snapshots/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
8
|
-
tests/snapshots/snap_base_tests.py,sha256=0Vc6Vjm8rLyPVbSRUu2xX8XVOEtU_pns2-oJE-EETyQ,27182
|
9
|
-
pyaterochka_api-0.1.7.dist-info/METADATA,sha256=F-2s2jK7CjylujQ8cd39NrdZpvyk_LPZRubDlPc8NIo,9291
|
10
|
-
pyaterochka_api-0.1.7.dist-info/WHEEL,sha256=DnLRTWE75wApRYVsjgc6wsVswC54sMSJhAEd4xhDpBk,91
|
11
|
-
pyaterochka_api-0.1.7.dist-info/top_level.txt,sha256=PXTSi8y2C5_Mz20pJJFqOUBnjAIAXP_cc38mthvJ2x4,22
|
12
|
-
pyaterochka_api-0.1.7.dist-info/RECORD,,
|
tests/snapshots/__init__.py
DELETED
File without changes
|