forked from mtusi2026/mtusi2026lab3
feat-(lab3 started, X-Instance-ID, Idempotence-Key in send_message method added)
This commit is contained in:
@@ -0,0 +1,48 @@
|
||||
import requests
|
||||
import uuid
|
||||
from conftest import base_url, auth
|
||||
|
||||
|
||||
def test_foreign_chat_get(base_url, eve, chat):
|
||||
response = requests.get(f"{base_url}/api/v1/chats/{chat['id']}",
|
||||
headers=auth(eve))
|
||||
assert response.status_code == 404
|
||||
assert response.json()["error"]["code"] == "not_found"
|
||||
|
||||
|
||||
def test_foreign_chat_messages(base_url, eve, chat):
|
||||
response = requests.get(f"{base_url}/api/v1/chats/{chat['id']}/messages",
|
||||
headers=auth(eve))
|
||||
assert response.status_code == 404
|
||||
assert response.json()["error"]["code"] == "not_found"
|
||||
|
||||
|
||||
def test_foreign_chat_send_messages(base_url, eve, chat):
|
||||
response = requests.post(f"{base_url}/api/v1/chats/{chat['id']}/messages",
|
||||
headers={**auth(eve), "Idempotency-Key": str(uuid.uuid4())},
|
||||
json={"text": "Hello, I miss you"},
|
||||
)
|
||||
assert response.status_code == 404
|
||||
assert response.json()["error"]["code"] == "not_found"
|
||||
|
||||
|
||||
def test_foreign_chat_not_in_list(base_url, eve, chat):
|
||||
response = requests.get(f"{base_url}/api/v1/chats?limit=100", headers=auth(eve))
|
||||
|
||||
assert response.status_code == 200
|
||||
chat_ids = [c["id"] for c in response.json()["items"]]
|
||||
assert chat["id"] not in chat_ids
|
||||
|
||||
|
||||
def test_invalid_chat_id_format(base_url, alice):
|
||||
response = requests.get(f"{base_url}/api/v1/chats/wrong_id",
|
||||
headers=auth(alice))
|
||||
assert response.status_code == 400
|
||||
assert response.json()["error"]["code"] == "invalid_request"
|
||||
|
||||
|
||||
def test_nonexistent_chat(base_url, alice):
|
||||
response = requests.get(f"{base_url}/api/v1/chats/00000000-0000-0000-0000-000000000000",
|
||||
headers=auth(alice))
|
||||
assert response.status_code == 404
|
||||
assert response.json()["error"]["code"] == "not_found"
|
||||
Reference in New Issue
Block a user