From 68a1a662e50e5fa3a671fee07c5a1ea7fd0c9889 Mon Sep 17 00:00:00 2001 From: Notime02 <94148329+Notime02@users.noreply.github.com> Date: Fri, 19 Jun 2026 21:13:40 +0300 Subject: [PATCH] fix(#1): [$30 BOUNTY] [Python] Expand backend API contract edge-case --- tests/backend_api/test_api_contract.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 tests/backend_api/test_api_contract.py diff --git a/tests/backend_api/test_api_contract.py b/tests/backend_api/test_api_contract.py new file mode 100644 index 00000000..c0c491dc --- /dev/null +++ b/tests/backend_api/test_api_contract.py @@ -0,0 +1,18 @@ +import pytest +from backend.api_contract import APIContract + +@pytest.mark.parametrize("payload, expected_error", [ + ({"missing_field": "value"}, "Missing required field: 'required_field'"), + ({"required_field": None}, "Invalid value for field: 'required_field'") +]) +def test_api_contract_negative_cases(payload, expected_error): + with pytest.raises(APIContract.Error) as exc_info: + APIContract.validate(payload) + assert str(exc_info.value) == expected_error + +@pytest.mark.asyncio +async def test_api_contract_async_wrapper(): + async def async_helper(): + return APIContract.validate({"required_field": "value"}) + result = await async_helper() + assert result == {"required_field": "value"}