diff options
Diffstat (limited to 'test/python/server_test_case.py')
| -rw-r--r-- | test/python/server_test_case.py | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/test/python/server_test_case.py b/test/python/server_test_case.py index be2dcf9..c400661 100644 --- a/test/python/server_test_case.py +++ b/test/python/server_test_case.py @@ -4,6 +4,7 @@ integration tests under tests/, which call the router in-process). """ import hashlib +import json import os import socket import struct @@ -17,6 +18,18 @@ HOST = "127.0.0.1" PORT = os.environ.get("GENENETWORK4_PORT", "3000") +def envelope_data(body): + """The `data` of a success response body, after checking that the + body is the standard envelope: `meta` (state, took_ms, request_id), + `notes` and `next` next to `data`.""" + envelope = json.loads(body) + assert isinstance(envelope["meta"]["state"], str), envelope + assert isinstance(envelope["meta"]["took_ms"], int), envelope + assert isinstance(envelope["notes"], list), envelope + assert isinstance(envelope["next"], list), envelope + return envelope["data"] + + def wait_for_port(host, port, timeout=10): deadline = time.time() + timeout while time.time() < deadline: |
