tests: Move 'plain_outdated_schema' message into conftest.py

This commit is contained in:
Athanasius 2022-08-19 17:19:56 +01:00
parent 795480f097
commit 4b6f22d9fd
No known key found for this signature in database
GPG Key ID: 8C392035DD80FD62
2 changed files with 19 additions and 14 deletions

View File

@ -7,6 +7,17 @@ import pytest
test_messages = {
'invalid_json': '{not real json',
'plain_outdated_schema': '''{
"$schemaRef": "http://schemas.elite-markets.net/eddn/journal/1",
"header": {
"uploaderID": "outdated schema",
"softwareName": "pytest:Gateway.parse_and_error_handle",
"softwareVersion": "v0.0.1"
},
"message": {
}
}''',
'plain_journal_scan_valid': '''{
"$schemaRef": "https://eddn.edcd.io/schemas/journal/1",
"header": {
@ -21,7 +32,9 @@ test_messages = {
"StarPos":[-30.12500,8.18750,-17.00000],
"SystemAddress":3932076118738
}
}'''
}''',
}

View File

@ -37,20 +37,12 @@ def test_invalid_json(fix_sys_path, eddn_gateway, eddn_message: Callable) -> Non
def test_outdated_schema(fix_sys_path, eddn_gateway, eddn_message: Callable) -> None:
"""Test attempt to use an outdated schema."""
msg = """
{
"$schemaRef": "http://schemas.elite-markets.net/eddn/journal/1",
"header": {
"uploaderID": "outdated schema",
"softwareName": "pytest:Gateway.parse_and_error_handle",
"softwareVersion": "v0.0.1"
},
"message": {
}
}
"""
msg = eddn_message('plain_outdated_schema')
res = eddn_gateway.parse_and_error_handle(msg.encode(encoding="utf-8"))
assert res.startswith("FAIL: Outdated Schema: The schema you have used is no longer supported. Please check for an updated version of your application.")
assert res.startswith(
"FAIL: Outdated Schema: The schema you have used is no longer supported."
" Please check for an updated version of your application."
)
def test_fail_validation_no_softwarename(fix_sys_path, eddn_gateway, eddn_message: Callable) -> None: