1
from unittest import mock
4
from sqlalchemy import func, select
7
async def test_crud_product_category(async_client, headers, stores, companies):
9
Проверяем rруд вокруг товаров
12
'company_id': companies[0].id.__str__(),
13
'external_number': '10001',
16
response = await async_client.post("/api/basic/product_category", json=create_data, headers=headers['superadmin'])
17
assert response.status_code == 200
18
data = response.json()
19
category_id_1 = data['id']
22
'company_id': companies[0].id.__str__(),
23
'external_number': '10002',
24
'title': 'Subcategory 1',
25
'parent_id': [category_id_1, ]
27
response = await async_client.post("/api/basic/product_category", json=create_data, headers=headers['superadmin'], )
28
assert response.status_code == 200
29
data = response.json()
30
category_id_2 = data['id']
34
'external_number': '10003 UPDATED',
35
'title': 'Subcategory 1 UPDATED ',
38
response = await async_client.put(f"/api/basic/product_category/{category_id_2}", json=update_data, headers=headers['superadmin'], )
39
assert response.status_code == 200
42
response = await async_client.get("/api/basic/product_category", headers=headers['superadmin'], params={'size': 100, 'search': 'Subcategory'}
44
assert response.status_code == 200
45
data = response.json()
46
assert len(data.get('data')) == 1
48
response = await async_client.delete(f"/api/basic/product_category/{category_id_2}", headers=headers['superadmin'], )
49
assert response.status_code == 200
50
response = await async_client.delete(f"/api/basic/product_category/{category_id_1}", headers=headers['superadmin'], )
51
assert response.status_code == 200
55
async def test_crud_product_storage_type(async_client, headers, stores, companies):
57
Проверяем rруд вокруг товаров
60
'company_id': companies[0].id.__str__(),
61
'external_number': '10001',
62
'title': 'product_storage_type 1'
64
response = await async_client.post("/api/basic/product_storage_type", json=create_data, headers=headers['superadmin'])
65
assert response.status_code == 200
66
data = response.json()
67
product_storage_type_id_1 = data['id']
70
'company_id': companies[0].id.__str__(),
71
'external_number': '10002',
72
'title': 'product_storage_type 2',
74
response = await async_client.post("/api/basic/product_storage_type", json=create_data, headers=headers['superadmin'], )
75
assert response.status_code == 200
76
data = response.json()
77
product_storage_type_id_2 = data['id']
81
'external_number': '10003 UPDATED',
82
'title': 'product_storage_type 1 UPDATED',
85
response = await async_client.put(f"/api/basic/product_storage_type/{product_storage_type_id_2}", json=update_data, headers=headers['superadmin'], )
86
assert response.status_code == 200
89
response = await async_client.get("/api/basic/product_storage_type", headers=headers['superadmin'], params={'size': 100, 'search': 'product_storage_type 1 UPDATED'}
91
assert response.status_code == 200
92
data = response.json()
93
assert len(data.get('data')) == 1
95
response = await async_client.delete(f"/api/basic/product_storage_type/{product_storage_type_id_2}", headers=headers['superadmin'], )
96
assert response.status_code == 200
97
response = await async_client.delete(f"/api/basic/product_storage_type/{product_storage_type_id_1}", headers=headers['superadmin'], )
98
assert response.status_code == 200