mirror of
https://github.com/EDCD/EDDN.git
synced 2025-04-27 21:52:14 +03:00
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:
parent
87c79a3427
commit
30282ba95e
32
src/tests/conftest.py
Normal file
32
src/tests/conftest.py
Normal 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
|
Loading…
x
Reference in New Issue
Block a user