From a23491f73fc3fea39867300cb024d55af8f0d8cd Mon Sep 17 00:00:00 2001 From: Athanasius Date: Mon, 29 Aug 2022 16:10:16 +0100 Subject: [PATCH] tests: Rename Gateway.handle_upload() test & move bottle.response mock to conftest.py fixture Gateway.handle_upload: Rename function to include 'valid' --- src/tests/conftest.py | 9 +++++++++ src/tests/gateway/test_handle_upload.py | 9 +++++++-- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/src/tests/conftest.py b/src/tests/conftest.py index 7f190e9..4737a8b 100644 --- a/src/tests/conftest.py +++ b/src/tests/conftest.py @@ -77,3 +77,12 @@ def eddn_gateway(): eddn.Gateway.configure() return eddn.Gateway + + +@pytest.fixture +def bottle_response() -> object: + """Mock a `bottle.response` enough for tests.""" + class BottleResponseMock: + status: int = 200 + + return BottleResponseMock() diff --git a/src/tests/gateway/test_handle_upload.py b/src/tests/gateway/test_handle_upload.py index 35f3a4b..4421069 100644 --- a/src/tests/gateway/test_handle_upload.py +++ b/src/tests/gateway/test_handle_upload.py @@ -2,7 +2,12 @@ from typing import Callable -def test_plain_message(fix_sys_path, eddn_gateway, eddn_message: Callable) -> None: +def test_valid_plain_message( + fix_sys_path, + eddn_message: Callable, + eddn_gateway, + bottle_response +) -> None: """Test eddn.Gateway with a plain message.""" #################################################################### # Mock a bottle 'response' enough to accept setting status @@ -17,7 +22,7 @@ def test_plain_message(fix_sys_path, eddn_gateway, eddn_message: Callable) -> No "Content-Type": "application/json" }, body=msg.encode(encoding="utf-8"), - response=BottleResponseMock() + response=bottle_response ) print(f"{resp_str=}")