-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathconftest.py
80 lines (71 loc) · 2.29 KB
/
conftest.py
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
import os
import pytest
import requests
from dotenv import load_dotenv
from tests_api.utils.checking import Checking
base_url = 'https://dbend.areso.pro' # Base url
@pytest.fixture()
def get_token():
"""
Method return:\n
token: str\n
body: dict\n
new_password: str\n
old_password: str\n
email: str
:returns: token: str, body: dict, new_password: str, old_password:str, email: str
"""
load_dotenv()
email = os.getenv('EMAIL')
old_password = os.getenv('PASSWORD')
new_password = '123456789'
try:
body = {"email": email, "password": f'{old_password}'}
result = requests.post('https://dbend.areso.pro/login', json=body)
token = result.json()['token']
if token != {}:
new_password, old_password = old_password, new_password
Checking.check_status_code(result, 200)
return token, body, new_password, old_password, email
except Exception as ex:
print(ex)
old_password, new_password = new_password, old_password
body = {"email": email, "password": f'{old_password}'}
result = requests.post('https://dbend.areso.pro/login', json=body)
token = result.json()['token']
Checking.check_status_code(result, 200)
return token, body, new_password, old_password, email
@pytest.fixture()
def get_token_backup_1():
"""
Method return:\n
token: str\n
body: dict\n
uuid: str
"""
load_dotenv()
email = os.getenv('BACKUP1_MAIL')
old_password = os.getenv('BACKUP1_PASSWORD')
uuid = os.getenv('BACKUP1_UUID')
body = {"email": email, "password": old_password}
result = requests.post('https://dbend.areso.pro/login', json=body)
Checking.check_status_code(result, 200)
token = result.json()['token']
return token, body, uuid
@pytest.fixture()
def get_token_backup_2():
"""
Method return:\n
token: str\n
body: dict\n
uuid: str
"""
load_dotenv()
email = os.getenv('BACKUP2_MAIL')
old_password = os.getenv('BACKUP2_PASSWORD')
uuid = os.getenv('BACKUP2_UUID')
body = {"email": email, "password": old_password}
result = requests.post('https://dbend.areso.pro/login', json=body)
Checking.check_status_code(result, 200)
token = result.json()['token']
return token, body, uuid