ЛР 2: мессенджер на PostgreSQL и сессии в Redis
Skeleton contracts / contracts (pull_request) Canceled after 0s
Skeleton contracts / contracts (pull_request) Canceled after 0s
This commit is contained in:
@@ -0,0 +1,39 @@
|
||||
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)
|
||||
Reference in New Issue
Block a user