1
from unittest import mock
4
from sqlalchemy import func, select
6
async def test_signup(async_client, headers):
9
"email": "SanyokGarbunek@vas.ru",
12
"phone_number": "+449534771093",
14
"password1": "string",
18
"title": "GORA I KOMUTA",
25
response = await async_client.post("/api/basic/user/signup", json=request_data)
26
assert response.status_code == 200
29
async def test_list_filter_company(async_client, headers):
31
Проверяем что работает список с фильтрами
33
response = await async_client.get(
35
headers=headers['superadmin'],
36
params={'size': 100, 'search': 'admin@admin.com'}
38
assert response.status_code == 200
39
data = response.json()
40
assert data['data'][0]['nickname'] == 'admin'
42
response = await async_client.get(
44
headers=headers['superadmin'],
45
params={'size': 100, 'search': 'vasya'}
47
assert response.status_code == 200
48
data = response.json()
49
assert len(data.get('data')) == 2
52
async def test_user_edit(async_client, headers):
53
response = await async_client.get(
55
headers=headers['superadmin'],
56
params={'size': 100, 'search': 'admin@admin.com'}
58
data = response.json()
59
user = data['data'][0]
60
assert user['nickname'] == 'admin'
62
'nickname': 'admin_edited'
65
response_edit = await async_client.put(f'/api/basic/user/{user_id}', json=body, headers=headers['superadmin'])
66
data = response_edit.json()
67
assert data['nickname'] == 'admin_edited'
68
assert response.status_code == 200
71
async def test_user_login(async_client, headers):
73
"email": "company_support@gmail.com",
76
response = await async_client.post(f'/api/basic/user/login', json=body)
77
assert response.status_code == 200
78
data = response.json()
79
assert data['nickname'] == 'Support vasya'
82
async def test_user_crud(async_client, headers, companies, roles):
84
Полный тест круда модельки
88
"email": "new@yandex.ru",
91
"phone_number": "449534771093",
92
"nickname": "new_support_user_for_company_1",
97
roles.get('support').id.hex
102
response = await async_client.post(f'/api/basic/user', json=body, headers=headers['company_admin'])
103
assert response.status_code == 200
104
data = response.json()
105
assert data['nickname'] == 'new_support_user_for_company_1'
110
'nickname': 'new_support_user_for_company_1_edited'
112
response_edit = await async_client.put(f'/api/basic/user/{user_id}', json=body, headers=headers['superadmin'])
113
data_create = response_edit.json()
114
assert data_create['nickname'] == 'new_support_user_for_company_1_edited'
115
assert response.status_code == 200
117
response_get = await async_client.get(f'/api/basic/user/{user_id}', headers=headers['superadmin'])
118
data_get = response_get.json()
119
assert data_get['nickname'] == 'new_support_user_for_company_1_edited'
120
assert response_get.status_code == 200
122
response_edit = await async_client.delete(f'/api/basic/user/{user_id}', headers=headers['superadmin'])
123
assert response_edit.status_code == 200
126
responce_delete_404 = await async_client.delete(f'/api/basic/user/{user_id}', headers=headers['superadmin'])
127
assert responce_delete_404.status_code == 404
129
responce_get_404 = await async_client.get(f'/api/basic/user/{user_id}', headers=headers['superadmin'])
130
assert responce_get_404.status_code == 404