feat: Саватеев А трек 4

This commit is contained in:
Enterxx2
2026-11-02 23:13:38 +03:00
parent 445cfe4789
commit 081d0fd2c8
76 changed files with 6387 additions and 77 deletions
+49 -1
View File
@@ -5,7 +5,15 @@ from pathlib import Path
import httpx
import pytest
from helpers import auth, basic, message_headers, unique_password, unique_username
from helpers import (
auth,
basic,
message_headers,
png_bytes,
unique_password,
unique_username,
upload_raw,
)
ROOT = Path(__file__).resolve().parents[1]
DEFAULT_BASE_URL = json.loads((ROOT / "lab.json").read_text())["default_base_url"]
@@ -74,3 +82,43 @@ def send_message(api: httpx.Client) -> Callable[..., dict]:
return response.json()
return send
@pytest.fixture
def upload(api: httpx.Client) -> Callable[..., dict]:
"""Успешная загрузка вложения: 201 и Attachment"""
def create(
user: dict,
chat: dict,
content: bytes | None = None,
content_type: str = "image/png",
filename: str = "image.png",
) -> dict:
response = upload_raw(
api, user, chat["id"], content or png_bytes(), content_type, filename
)
assert response.status_code == 201, response.text
return response.json()
return create
@pytest.fixture
def send_attachments(api: httpx.Client) -> Callable[..., httpx.Response]:
"""POST сообщения с attachment_ids; ответ не проверяется"""
def send(
user: dict,
chat: dict,
attachment_ids: list[str],
text: str = "",
key: str | None = None,
) -> httpx.Response:
return api.post(
f"/api/v1/chats/{chat['id']}/messages",
json={"text": text, "attachment_ids": attachment_ids},
headers=message_headers(user, key),
)
return send