1
from unittest import mock
4
from sqlalchemy import func, select
6
async def test_list_filter_store(async_client, headers, stores):
8
Проверяем что работает список с фильтрами
10
response = await async_client.get(
12
headers=headers['superadmin'],
15
assert response.status_code == 200
16
data = response.json()
17
assert len(data.get('data')) == 2
19
response = await async_client.get(
21
headers=headers['superadmin'],
22
params={'size': 100, 'search': 'Store company 1'}
24
assert response.status_code == 200
25
data = response.json()
26
assert len(data.get('data')) == 1
29
async def test_update_store(async_client, headers, stores):
30
response = await async_client.get(f"/api/basic/project/{stores[0].id.__str__()}")
31
assert response.status_code == 401
33
'title': 'Store company 1 UPDATED',
34
'address': 'Adress UPDATED',
35
'external_number': 'ADRESS UPDATED'
38
response = await async_client.put(f"/api/basic/project/{stores[0].id.__str__()}", json=update_json, headers=headers['superadmin'])
39
assert response.status_code == 200
40
data = response.json()
41
assert data['title'] == update_json['title']
42
assert data['address'] == update_json['address']
43
assert data['external_number'] == update_json['external_number']
46
async def test_crud_store(async_client, headers, companies):
48
"title": "Created project",
49
"address": "Created address",
50
"external_number": "created external id",
51
"company_id": companies[0].id.__str__(),
53
response = await async_client.post("/api/basic/project", json=request_data, headers=headers['superadmin'])
54
assert response.status_code == 200
55
data = response.json()
56
assert data['title'] == request_data['title']
57
assert data['company_rel']['id'] == request_data['company_id']
58
response = await async_client.delete(f"/api/basic/project/{data['id']}", headers=headers['superadmin'])
59
assert response.status_code == 200