реализация второй лабы

This commit is contained in:
Ванек
2026-10-22 17:16:01 +03:00
parent 9961362555
commit 0dfbfe35f8
43 changed files with 5114 additions and 337 deletions
+7 -5
View File
@@ -25,6 +25,8 @@ class ApiTests(ApiTestCase):
{"username": "valid_name", "display_name": "Имя", "extra": 1},
]
for body in invalid_bodies:
if isinstance(body, dict):
body = {**body, "password": "Synthetic-password-123"}
with self.subTest(body=body):
self.assert_error("POST", "/api/v1/users", 400, "invalid_request",
raw=json.dumps(body).encode(), headers={"Content-Type": "application/json"})
@@ -47,13 +49,13 @@ class ApiTests(ApiTestCase):
def test_identification_and_authentication_order(self):
self.assert_error("GET", "/api/v1/users/me", 401, "unauthorized")
self.assert_error("GET", "/api/v1/users/me", 401, "unauthorized",
headers={"X-User-Id": str(uuid4())})
self.assert_error("GET", "/api/v1/users/me", 400, "invalid_request",
headers={"X-User-Id": "not-a-uuid"})
headers={"X-User-Id": self.alice["id"]})
self.assert_error("GET", "/api/v1/users/me", 401, "unauthorized",
headers={"Authorization": "Bearer unknown-session"})
self.assert_error("POST", self.path + "/messages", 401, "unauthorized",
raw=b'{', headers={"Content-Type": "application/json"})
me = self.client.call("GET", "/api/v1/users/me", schema="User",
headers={"X-User-Id": self.alice["id"].upper()})["json"]
me = self.client.call("GET", "/api/v1/users/me", schema="User", actor=self.alice,
headers={"X-User-Id": self.bob["id"]})["json"]
self.assertEqual(me, self.alice["user"])
def test_invalid_chat_members(self):