mirror of
https://github.com/EDCD/EDDN.git
synced 2025-04-27 13:42:14 +03:00
tests: Gateway: parse_and_error_handle: Two tests to get started
This is Athanasius feeling out how best to add tests to this ancient code. * Test that eddn.Gateway.parse_and_error_handle() returns the correct error string for: - Invalid JSON being passed in. - An outdated schema being cited.
This commit is contained in:
parent
76251cfd30
commit
ddf9f3524f
28
src/tests/gateway/test_parse_and_error_handle.py
Normal file
28
src/tests/gateway/test_parse_and_error_handle.py
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
import os
|
||||||
|
import sys
|
||||||
|
|
||||||
|
# Tests don't include the directory that `pytest` is run from on sys.path
|
||||||
|
sys.path.append(os.getcwd())
|
||||||
|
|
||||||
|
import eddn.Gateway
|
||||||
|
|
||||||
|
def test_bad_json():
|
||||||
|
msg = "{not real json"
|
||||||
|
res = eddn.Gateway.parse_and_error_handle(msg.encode(encoding="utf-8"))
|
||||||
|
assert res.startswith("FAIL: JSON parsing: ")
|
||||||
|
|
||||||
|
def test_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": {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
"""
|
||||||
|
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.")
|
Loading…
x
Reference in New Issue
Block a user