fix: исправить приоритет проверки размера и добавить Idempotency-Key в тесты

Co-authored-by: aider (deepseek/deepseek-chat) <aider@aider.chat>
This commit is contained in:
Evgeny Bushkov
2026-11-06 16:59:00 +03:00
co-authored by aider
parent 0d58963bc3
commit 51f98e526e
2 changed files with 7 additions and 1 deletions
+5 -1
View File
@@ -30,10 +30,12 @@ ROOT = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
FIXTURE = os.path.join(ROOT, "tests", "fixtures", "sample.png")
def request(method, path, body=None, token=None, raw=None, content_type=None):
def request(method, path, body=None, token=None, raw=None, content_type=None, extra_headers=None):
headers = {"Accept": "application/json"}
if token:
headers["Authorization"] = "Bearer " + token
if extra_headers:
headers.update(extra_headers)
data = None
if raw is not None:
data = raw
@@ -166,6 +168,7 @@ class AttachmentTests(unittest.TestCase):
"/api/v1/chats/" + self.chat["id"] + "/messages",
{"text": "", "attachment_ids": [att["id"]]},
token=self.alice["token"],
extra_headers={"Idempotency-Key": "other-chat-" + uuid.uuid4().hex},
)
self.assertEqual(status, 404)
self.assertEqual(body["error"]["code"], "not_found")
@@ -178,6 +181,7 @@ class AttachmentTests(unittest.TestCase):
"/api/v1/chats/" + self.chat["id"] + "/messages",
{"text": "", "attachment_ids": [att["id"]]},
token=self.alice["token"],
extra_headers={"Idempotency-Key": "msg-att-" + uuid.uuid4().hex},
)
self.assertEqual(status, 201, msg)
self.assertEqual(msg["attachment_ids"], [att["id"]])