Skip to content

Instantly share code, notes, and snippets.

@mattstibbs
Created May 21, 2018 07:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mattstibbs/c3fc1380f968068cd13df28f3b58e57e to your computer and use it in GitHub Desktop.
Save mattstibbs/c3fc1380f968068cd13df28f3b58e57e to your computer and use it in GitHub Desktop.
Mocking log line test
def test_log_line_written_ods_code():
u = User('test-username', 'test-password')
client = RestApiClient(u)
identifier = 'A91547'
data = {
'success':
{
'serviceCount': 1,
'services':
[
{'id': 'A91547', 'name': 'Test Service', 'endpoints': []}
]
}
}
with mock.patch.object(client.s, 'get') as get:
mock_response = get.return_value
mock_response.json.return_value = data
with mock.patch.object(rest_api.logger, 'debug') as log:
client.get_single_service(identifier, 'ods')
log.assert_any_call(f'get_single_service response id = {identifier}')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment