tests: Gateway.handle_upload: invalid message

This commit is contained in:
Athanasius 2022-08-29 16:30:08 +01:00
parent a23491f73f
commit b6c703fa64
No known key found for this signature in database
GPG Key ID: 8C392035DD80FD62

View File

@ -27,3 +27,30 @@ def test_valid_plain_message(
print(f"{resp_str=}")
assert resp_str.startswith("OK")
def test_invalid_message(
fix_sys_path,
eddn_message: Callable,
eddn_gateway,
bottle_response
) -> None:
"""Test eddn.Gateway with an invalid message."""
####################################################################
# Mock a bottle 'response' enough to accept setting status
####################################################################
class BottleResponseMock:
status: int = 200
####################################################################
msg = eddn_message("invalid_json")
resp_str = eddn_gateway.handle_upload(
headers={
"Content-Type": "application/json"
},
body=msg.encode(encoding="utf-8"),
response=bottle_response
)
print(f"{resp_str=}")
assert resp_str.startswith("FAIL: JSON parsing: ")