diff --git a/src/tests/conftest.py b/src/tests/conftest.py index b606acf..7f8d0e5 100644 --- a/src/tests/conftest.py +++ b/src/tests/conftest.py @@ -1,5 +1,6 @@ """General pytest configuration, including fixtures.""" import os +import pathlib import sys from typing import Callable, Optional @@ -89,6 +90,17 @@ test_messages = { } +@pytest.fixture() +def eddn_message_from_file() -> Callable: + """Load and supply a test message from the on-disk collection.""" + def _method(msg_type: str) -> Optional[str]: + path = pathlib.Path('tests/eddn_message/' + msg_type) + with open(path, 'r') as eddn_message: + return eddn_message.read() + + return _method + + @pytest.fixture def eddn_message() -> Callable: """Supply the requested test message.""" diff --git a/src/tests/gateway/test_parse_and_error_handle.py b/src/tests/gateway/test_parse_and_error_handle.py index 90c86ce..85d622b 100644 --- a/src/tests/gateway/test_parse_and_error_handle.py +++ b/src/tests/gateway/test_parse_and_error_handle.py @@ -26,9 +26,9 @@ def test_fail_validation_no_softwarename(fix_sys_path, eddn_gateway, eddn_messag assert res.startswith("FAIL: Schema Validation: []") -def test_valid_journal_scan(fix_sys_path, eddn_gateway, eddn_message: Callable) -> None: +def test_valid_journal_scan(fix_sys_path, eddn_gateway, eddn_message_from_file: Callable) -> None: """Test a valid journal/1, `event == 'Scan'` message.""" - msg = eddn_message('plain_journal_scan_valid') + msg = eddn_message_from_file('journal/1/scan/valid.json') res = eddn_gateway.parse_and_error_handle(msg.encode(encoding="utf-8")) assert res == "OK"