tests: Gateway: Add commodity/3 test message & use against parse_and_error_handle()

This commit is contained in:
Athanasius 2022-08-29 16:53:07 +01:00
parent e205b56b21
commit 3f5c2bff7f
No known key found for this signature in database
GPG Key ID: 8C392035DD80FD62
2 changed files with 36 additions and 2 deletions

View File

@ -13,7 +13,7 @@ test_messages = {
"$schemaRef": "http://schemas.elite-markets.net/eddn/journal/1",
"header": {
"uploaderID": "outdated schema",
"softwareName": "pytest:Gateway.parse_and_error_handle",
"softwareName": "pytest:src/",
"softwareVersion": "v0.0.1"
},
"message": {
@ -34,7 +34,7 @@ test_messages = {
"$schemaRef": "https://eddn.edcd.io/schemas/journal/1",
"header": {
"uploaderID": "valid journal message",
"softwareName": "pytest:Gateway.parse_and_error_handle",
"softwareName": "pytest:src/",
"softwareVersion": "v0.0.1"
},
"message": {
@ -45,6 +45,33 @@ test_messages = {
"SystemAddress":3932076118738
}
}''',
'plain_commodity_valid': '''{
"$schemaRef": "https://eddn.edcd.io/schemas/commodity/3",
"header": {
"uploaderID": "valid journal message",
"softwareName": "pytest:src/",
"softwareVersion": "v0.0.1"
},
"message": {
"timestamp":"2021-11-05T15:46:28Z",
"systemName":"LP 98-132",
"stationName":"Freeport",
"marketId":128008448,
"commodities":[
{
"name":"$platinum_name;",
"buyPrice":39557,
"sellPrice":39555,
"meanPrice":58263,
"stockBracket":0,
"demandBracket":0,
"stock":0,
"demand":0
}
]
}
}''',
}

View File

@ -31,3 +31,10 @@ def test_valid_journal_scan(fix_sys_path, eddn_gateway, eddn_message: Callable)
msg = eddn_message('plain_journal_scan_valid')
res = eddn_gateway.parse_and_error_handle(msg.encode(encoding="utf-8"))
assert res == "OK"
def test_valid_commodity(fix_sys_path, eddn_gateway, eddn_message: Callable) -> None:
"""Test a valid commodity/3 message."""
msg = eddn_message('plain_commodity_valid')
res = eddn_gateway.parse_and_error_handle(msg.encode(encoding="utf-8"))
assert res == "OK"