From fa3e919ad49fefbcfd3291cd031527bf71da5326 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=93=D0=BE=D0=BB=D0=B8=D0=BA=D0=BE=D0=B2=20Maximillian?= =?UTF-8?q?=20=D0=90=D0=BD=D1=82=D0=BE=D0=BD?= Date: Fri, 23 Oct 2026 11:27:08 +0300 Subject: [PATCH] fix(student-tests):lab4 parse JSON body for 201 uploads --- student-tests/test_attachments.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/student-tests/test_attachments.py b/student-tests/test_attachments.py index 560bf6dc..d63e4c04 100644 --- a/student-tests/test_attachments.py +++ b/student-tests/test_attachments.py @@ -20,9 +20,11 @@ def upload(c, actor, chat, content, content_type, filename='x.png', expected=201 actor=actor, raw=content, headers={'Content-Type': content_type}, + schema='Attachment', ) + def main(): args = arguments('Негативные сценарии вложений') c = Client(args.base_url, args.ca_file) @@ -35,10 +37,10 @@ def main(): '11 MiB: ожидался payload_too_large') # 2. Битый PNG (обрезанный header) -> 415 - broken = SAMPLE[:100] + broken = b'\x89PNG\r\n\x1a\n' + b'\x00' * 32 r = upload(c, alice, chat, broken, 'image/png', expected=415) check(r['json']['error']['code'] == 'unsupported_media_type', - 'битый PNG: ожидался unsupported_media_type') + 'битый PNG (нет IHDR): ожидался unsupported_media_type') # 3. MIME-подмена: PNG-байты с Content-Type image/jpeg -> 201, но content_type image/png r = upload(c, alice, chat, SAMPLE, 'image/jpeg')