-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconftest.py
More file actions
47 lines (40 loc) · 1.57 KB
/
conftest.py
File metadata and controls
47 lines (40 loc) · 1.57 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
import pytest
import requests
import allure
from src.config import Config
from src.helpers import register_new_courier_and_return_login_password
from src.data import ResponseCodes, VALID_COURIER, INVALID_COURIERS, ORDER_DATA
@pytest.fixture
def new_courier():
with allure.step('Создание нового курьера'):
courier_data = register_new_courier_and_return_login_password()
login = courier_data[0] + '_test'
password = courier_data[1]
first_name = courier_data[2] if len(courier_data) > 2 else ""
courier_payload = {
'login': login,
'password': password,
'firstName': first_name
}
yield courier_payload
with allure.step("Удаление тестового курьера"):
login, password = courier_data[0], courier_data[1]
payload = {
'login': login,
'password': password
}
login_response = requests.post(f'{Config.URL}{Config.COURIER_LOGIN_URL}', data = payload)
if login_response.status_code == ResponseCodes.OK:
courier_id = login_response.json().get('id')
requests.delete(f'{Config.URL}/courier/{courier_id}')
@pytest.fixture
def auth_courier():
return VALID_COURIER.copy()
@pytest.fixture
def unauth_courier():
return INVALID_COURIERS.copy()
@pytest.fixture
def new_order():
response = requests.post(f'{Config.URL}{Config.ORDER_URL}', json=ORDER_DATA)
track = response.json()['track']
yield {'track': track, 'order_data': ORDER_DATA}