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.
This commit is contained in:
Athanasius 2022-08-19 15:01:43 +01:00
parent 87c79a3427
commit 30282ba95e
No known key found for this signature in database
GPG Key ID: 8C392035DD80FD62

32
src/tests/conftest.py Normal file
View File

@ -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