From dbca33686234d26afc5b34d6bb91cf0f414c2f01 Mon Sep 17 00:00:00 2001 From: Ruwan Date: Tue, 20 Jun 2023 06:02:47 +0200 Subject: [PATCH] Update tests for when no request body is defined --- tests/decorators/test_parameter.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/tests/decorators/test_parameter.py b/tests/decorators/test_parameter.py index 81f63efe4..e727cce97 100644 --- a/tests/decorators/test_parameter.py +++ b/tests/decorators/test_parameter.py @@ -29,13 +29,14 @@ def handler(**kwargs): func(**kwargs) operation = MagicMock(name="operation") + operation.request_body = {} operation.body_name = lambda _: "body" with TestContext(operation=operation): parameter_decorator = SyncParameterDecorator(framework=FlaskFramework) decorated_handler = parameter_decorator(handler) decorated_handler(request) - func.assert_called_with(p1="123", body={}) + func.assert_called_with(p1="123") @pytest.mark.skipif( @@ -53,13 +54,14 @@ async def handler(**kwargs): func(**kwargs) operation = MagicMock(name="operation") + operation.request_body = {} operation.body_name = lambda _: "body" with TestContext(operation=operation): parameter_decorator = AsyncParameterDecorator(framework=StarletteFramework) decorated_handler = parameter_decorator(handler) await decorated_handler(request) - func.assert_called_with(p1="123", body={}) + func.assert_called_with(p1="123") def test_sync_injection_with_context(): @@ -75,13 +77,14 @@ def handler(context_, **kwargs): context = {"test": "success"} operation = MagicMock(name="operation") + operation.request_body = {} operation.body_name = lambda _: "body" with TestContext(context=context, operation=operation): parameter_decorator = SyncParameterDecorator(framework=FlaskFramework) decorated_handler = parameter_decorator(handler) decorated_handler(request) - func.assert_called_with(context, p1="123", test="success", body={}) + func.assert_called_with(context, p1="123", test="success") @pytest.mark.skipif( @@ -101,13 +104,14 @@ async def handler(context_, **kwargs): context = {"test": "success"} operation = MagicMock(name="operation") + operation.request_body = {} operation.body_name = lambda _: "body" with TestContext(context=context, operation=operation): parameter_decorator = AsyncParameterDecorator(framework=StarletteFramework) decorated_handler = parameter_decorator(handler) await decorated_handler(request) - func.assert_called_with(context, p1="123", test="success", body={}) + func.assert_called_with(context, p1="123", test="success") def test_pythonic_params():