1
from unittest import mock
4
from sqlalchemy import func, select
7
async def test_create_company(async_client, headers):
9
"title": "Test Company",
11
"external_number": "2131231231",
15
response = await async_client.post("/api/basic/company", json=request_data)
16
assert response.status_code == 401
17
response = await async_client.post("/api/basic/company", json=request_data, headers=headers['superadmin'])
18
assert response.status_code == 200
19
data = response.json()
20
assert data['title'] == "Test Company"
21
assert data['lsn'] > 0
24
async def test_list_company(async_client, headers, companies):
25
response = await async_client.get("/api/basic/company")
26
assert response.status_code == 401
27
response = await async_client.get("/api/basic/company", headers=headers['superadmin'])
28
assert response.status_code == 200
29
data = response.json()
33
async def test_update_company(async_client, headers, companies):
34
response = await async_client.get(f"/api/basic/company/{companies[0].id.__str__()}")
35
assert response.status_code == 401
37
'title': 'Great Apple',
41
response = await async_client.put(f"/api/basic/company/{companies[0].id.__str__()}", json=update_json, headers=headers['superadmin'])
42
assert response.status_code == 200
43
data = response.json()
44
assert data['title'] == 'Great Apple'
45
assert data['currency']['code'] == 'RUB'
46
assert data['country']['code'] == 'RU'
49
async def test_list_filter_company(async_client, headers, companies):
50
response = await async_client.get("/api/basic/company", headers=headers['superadmin'], params={'size': 100, 'currency': 'RUB'})
51
assert response.status_code == 200
52
data = response.json()
53
assert len(data.get('data')) == 1
55
response = await async_client.get("/api/basic/company", headers=headers['superadmin'], params={'size': 100, 'search': 'Company 2'})
56
assert response.status_code == 200
57
data = response.json()
58
assert len(data.get('data')) == 1