From 1233d7ee55d5d59a1a78ae56a18ae79a6898b687 Mon Sep 17 00:00:00 2001 From: shidron Date: Tue, 16 Jun 2026 08:57:03 +0300 Subject: [PATCH] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB=D0=B5?= =?UTF-8?q?=D0=BD=D0=B8=D0=B5=20py=20=D1=82=D0=B5=D1=81=D1=82=D0=BE=D0=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Tests/1_user.py | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 Tests/1_user.py diff --git a/Tests/1_user.py b/Tests/1_user.py new file mode 100644 index 0000000..4a60175 --- /dev/null +++ b/Tests/1_user.py @@ -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()) \ No newline at end of file