You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I need a way to check JSON data in requests made in views. I didn't find something in requests-mock. So i implement a simple function to check the mock.request_history
Usage looks like this:
with requests_mock.mock() as m:
m.post('http://test.tld', text='resp')
requests.post('http://test.tld', json={'foo': 'bar'}) # maybe this is made deeper e.g.: in a view
assert_json_requests_mock(mock=m, data=[{
'request': 'POST http://test.tld/',
'json': {'foo': 'bar'},
}])
I need a way to check JSON data in requests made in views. I didn't find something in requests-mock. So i implement a simple function to check the
mock.request_history
Usage looks like this:
The code is here: https://github.com/boxine/bx_py_utils/blob/master/bx_py_utils/test_utils/requests_mock_assertion.py
More examples are here: https://github.com/boxine/bx_py_utils/blob/master/bx_py_utils_tests/tests/test_requests_mock_assertion.py
Maybe this is useful for other users? Any interests to include this into requests-mock? Then i can try to create a pull request.
The text was updated successfully, but these errors were encountered: