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)