forked from mtusi2026/mtusi2026lab5
27 lines
763 B
Python
27 lines
763 B
Python
import json
|
|
from uuid import uuid4
|
|
|
|
import pytest
|
|
from conftest import check, headers
|
|
|
|
|
|
@pytest.mark.parametrize("encoding", ["utf-16", "utf-32"])
|
|
def test_only_utf8_json(client, encoding):
|
|
payload = {"username": "u_" + uuid4().hex[:20], "display_name": "UTF"}
|
|
payload["password"] = "Synthetic-encoding-test-123"
|
|
result = client.post(
|
|
"/api/v1/users",
|
|
content=json.dumps(payload).encode(encoding),
|
|
headers={"Content-Type": "application/json"},
|
|
)
|
|
check(result, 400, "Error")
|
|
|
|
|
|
def test_leading_zero_limit(client, actors, chat):
|
|
result = client.get(
|
|
"/api/v1/chats/" + chat["id"] + "/messages",
|
|
headers=headers(actors[0]),
|
|
params={"limit": "0001"},
|
|
)
|
|
check(result, 200, "MessagePage")
|