Files
mtusi2026lab2/tests/test_auth_and_transactions.py
T
vozzhin 1dd701be2b
Skeleton contracts / contracts (pull_request) Canceled after 0s
ЛР 2: мессенджер на PostgreSQL и сессии в Redis
2026-10-23 12:16:56 +03:00

40 lines
1022 B
Python

import base64
from uuid import uuid4
def test_rejects_incorrect_basic_password(client):
actor = client.user('wrong_password')
credentials = base64.b64encode(
(actor['registration']['username'] + ':definitely-wrong-password').encode('utf-8')
).decode('ascii')
client.call(
'POST',
'/api/v1/auth/sessions',
401,
headers={'Authorization': 'Basic ' + credentials},
)
def test_chat_creation_rolls_back_when_a_member_does_not_exist(client):
actor = client.user('chat_rollback')
title = 'Не должен сохраниться ' + uuid4().hex
client.call(
'POST',
'/api/v1/chats',
400,
actor=actor,
body={
'title': title,
'member_ids': [actor['id'], str(uuid4())],
},
)
chats = client.call(
'GET',
'/api/v1/chats?limit=100',
actor=actor,
schema='ChatPage',
)['json']['items']
assert all(chat['title'] != title for chat in chats)