def test_failed_put_with_stacktrace(session: Session): with requests_mock.Mocker() as m: m.put('http://citrine-testing.fake/api/v1/bad-endpoint', status_code=500, json={'debug_stacktrace': 'blew up!'}) with pytest.raises(Exception) as e: session.put_resource('/bad-endpoint', json={}) assert '{"debug_stacktrace": "blew up!"}' == str(e.value)
def test_good_json_response(session: Session): with requests_mock.Mocker() as m: json_to_validate = {"bar": "something"} m.put('http://citrine-testing.fake/api/v1/bar/something', status_code=200, json=json_to_validate) response_json = session.put_resource('bar/something', {"ignored": "true"}) assert response_json == json_to_validate