forked from mtusi2026/mtusi2026lab2
Возвращать 415 unsupported_media_type для неподдерживаемого Content-Type
Запрос с Content-Type, отличным от application/json, раньше получал 400 invalid_request. Теперь _json_body отвечает 415 unsupported_media_type (ApiError через новую функцию unsupported_media_type в errors.py), как предусмотрено контрактом. Повреждённый JSON с верным Content-Type по-прежнему даёт 400. Тест проверяет точный код ответа на регистрации, создании чата и отправке сообщения; число тестов 73 -> 76, evidence/tests.txt обновлён. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
+1
-1
@@ -14,6 +14,6 @@
|
||||
"ordered_by_created_at_and_id": true,
|
||||
"pages_read": 15,
|
||||
"page_size": 7,
|
||||
"send_elapsed_seconds": 0.407,
|
||||
"send_elapsed_seconds": 0.336,
|
||||
"ok": true
|
||||
}
|
||||
|
||||
+7
-4
@@ -1,5 +1,5 @@
|
||||
# Tests against the compose stand (docker compose up -d --build --wait).
|
||||
# Date: 2026-10-07 16:03 UTC
|
||||
# Date: 2026-10-23 10:13 UTC
|
||||
# Host: Windows 11, Docker Desktop engine 29.8.1, Compose 5.5.1, Python 3.14.7 for the test clients;
|
||||
# Intel Core Ultra 9 185H (16 cores, 22 threads), 31 GiB RAM, no CPU/RAM limits on containers.
|
||||
# Code: working tree of the solution branch (commit is given in REPORT.md).
|
||||
@@ -64,12 +64,15 @@ test_unknown_member_rolls_back_the_whole_chat (test_validation.ChatValidationTes
|
||||
test_valid_chat_keeps_member_order (test_validation.ChatValidationTest.test_valid_chat_keeps_member_order) ... ok
|
||||
test_extra_fields (test_validation.InvalidJsonTest.test_extra_fields) ... ok
|
||||
test_invalid_utf8 (test_validation.InvalidJsonTest.test_invalid_utf8) ... ok
|
||||
test_json_content_type_with_charset_is_accepted (test_validation.InvalidJsonTest.test_json_content_type_with_charset_is_accepted) ... ok
|
||||
test_json_that_is_not_an_object (test_validation.InvalidJsonTest.test_json_that_is_not_an_object) ... ok
|
||||
test_lone_surrogate_is_rejected_not_crashed (test_validation.InvalidJsonTest.test_lone_surrogate_is_rejected_not_crashed) ... ok
|
||||
test_malformed_json_on_message (test_validation.InvalidJsonTest.test_malformed_json_on_message) ... ok
|
||||
test_malformed_json_on_register (test_validation.InvalidJsonTest.test_malformed_json_on_register) ... ok
|
||||
test_malformed_json_with_right_content_type_stays_400 (test_validation.InvalidJsonTest.test_malformed_json_with_right_content_type_stays_400) ... ok
|
||||
test_nul_character_is_rejected_not_crashed (test_validation.InvalidJsonTest.test_nul_character_is_rejected_not_crashed) ... ok
|
||||
test_wrong_content_type (test_validation.InvalidJsonTest.test_wrong_content_type) ... ok
|
||||
test_wrong_content_type_is_415 (test_validation.InvalidJsonTest.test_wrong_content_type_is_415) ... ok
|
||||
test_wrong_content_type_on_chat_and_message_is_415 (test_validation.InvalidJsonTest.test_wrong_content_type_on_chat_and_message_is_415) ... ok
|
||||
test_wrong_types (test_validation.InvalidJsonTest.test_wrong_types) ... ok
|
||||
test_empty_message_is_400 (test_validation.MessageValidationTest.test_empty_message_is_400) ... ok
|
||||
test_missing_or_wrong_text (test_validation.MessageValidationTest.test_missing_or_wrong_text) ... ok
|
||||
@@ -88,7 +91,7 @@ test_unicode_display_name_is_kept (test_validation.UserValidationTest.test_unico
|
||||
test_username_length_limits_are_accepted (test_validation.UserValidationTest.test_username_length_limits_are_accepted) ... ok
|
||||
|
||||
----------------------------------------------------------------------
|
||||
Ran 73 tests in 8.689s
|
||||
Ran 76 tests in 7.839s
|
||||
|
||||
OK
|
||||
[exit code 0]
|
||||
@@ -110,7 +113,7 @@ $ BASE_URL=http://127.0.0.1:8080 python student-tests/race.py --output evidence/
|
||||
"ordered_by_created_at_and_id": true,
|
||||
"pages_read": 15,
|
||||
"page_size": 7,
|
||||
"send_elapsed_seconds": 0.407,
|
||||
"send_elapsed_seconds": 0.336,
|
||||
"ok": true
|
||||
}
|
||||
PASS
|
||||
|
||||
Reference in New Issue
Block a user