Добавление py тестов

This commit is contained in:
2026-06-16 08:57:03 +03:00
parent 3f7c24a885
commit 1233d7ee55

34
Tests/1_user.py Normal file
View File

@@ -0,0 +1,34 @@
import requests
token = ''
url_x_csrftoken = 'http://127.0.0.1:8000/api/get_xcsrf/'
response = requests.get(url_x_csrftoken)
x_csrftoken = response.json().get('X-CSRFToken')
cookies = response.cookies
cookies_dict = cookies.get_dict()
csrftoken = cookies_dict.get('csrftoken')
url = 'http://127.0.0.1:8000/api/users/'
headers = {
'Authorization': f'Bearer {token}',
'X-CSRFToken': x_csrftoken,
'Cookie': f'csrftoken={csrftoken}'
}
data = {
"lastname": "Qweqov",
"firstname": "Petr",
"middlename": "Qweyekovich",
"username": "PetrQweqov",
"password": "PetrQweqov@yandex.ru",
"email": "PetrQweqov@yandex.ru",
"phone": "89009401234",
}
response = requests.post(url, headers=headers, data=data)
print(response.status_code)
print(response.content)
print(response.json())