From 30282ba95eabced71c476008d5dcb742dc24649c Mon Sep 17 00:00:00 2001 From: Athanasius Date: Fri, 19 Aug 2022 15:01:43 +0100 Subject: [PATCH] tests/conftest: pytest top-level configuration, mostly Fixtures * `eddn_message()` fixture, set up to return a method when used, such that *that* can be called with a key to look up the approproiate test message. * `test_messages` dictionary to support that. --- src/tests/conftest.py | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 src/tests/conftest.py diff --git a/src/tests/conftest.py b/src/tests/conftest.py new file mode 100644 index 0000000..c9310f1 --- /dev/null +++ b/src/tests/conftest.py @@ -0,0 +1,32 @@ +"""General pytest configuration, including fixtures.""" +from typing import Callable, Optional + +import pytest + +"""A dictionary of test messages, all in string form.""" +test_messages = { + 'plain_journal_scan_valid': '''{ + "$schemaRef": "https://eddn.edcd.io/schemas/journal/1", + "header": { + "uploaderID": "valid journal message", + "softwareName": "pytest:Gateway.parse_and_error_handle", + "softwareVersion": "v0.0.1" + }, + "message": { + "timestamp":"2021-11-05T15:46:28Z", + "event":"Scan", + "StarSystem":"Elphin", + "StarPos":[-30.12500,8.18750,-17.00000], + "SystemAddress":3932076118738 + } + }''' +} + + +@pytest.fixture +def eddn_message() -> Callable: + """Supply the requested test message.""" + def _method(msg_type: str) -> Optional[str]: + return test_messages.get(msg_type) + + return _method