bot testing: Improve checking of fixtures in mock_http_conversation.
This ensures required fields are present in the fixture dict/json, improving testing & allowing file to pass mypy with strict-optional.
This commit is contained in:
parent
438f711bb7
commit
9853d85fb7
|
@ -43,9 +43,14 @@ def mock_http_conversation(http_data):
|
||||||
|
|
||||||
mock_result.assert_called_with(http_request['api_url'], **args)
|
mock_result.assert_called_with(http_request['api_url'], **args)
|
||||||
|
|
||||||
http_request = http_data.get('request')
|
try:
|
||||||
http_response = http_data.get('response')
|
http_request = http_data['request']
|
||||||
http_headers = http_data.get('response-headers')
|
http_response = http_data['response']
|
||||||
|
http_headers = http_data['response-headers']
|
||||||
|
except KeyError:
|
||||||
|
print("ERROR: Failed to find 'request', 'response' or 'response-headers' fields in fixture")
|
||||||
|
raise
|
||||||
|
|
||||||
http_method = http_request.get('method', 'GET')
|
http_method = http_request.get('method', 'GET')
|
||||||
|
|
||||||
if http_method == 'GET':
|
if http_method == 'GET':
|
||||||
|
|
Loading…
Reference in a new issue