def test_handle_response_successful(mocker): response = mocker.Mock(spec=Response) mocker.patch.object(response, 'json', mocker.Mock(return_value={'success': True})) assert dsctl.handle_response(response, '') is True
def test_handle_response_not_json(mocker, throws_json_decode_error): response = mocker.Mock(spec=Response) mocker.patch.object(response, 'json', throws_json_decode_error) assert dsctl.handle_response(response, '') is False
def test_handle_response_not_valid_json(mocker): response = mocker.Mock(spec=Response) mocker.patch.object(response, 'json', mocker.Mock(return_value={})) assert dsctl.handle_response(response, '') is False
def test_handle_response_not_ok(mocker): response = mocker.Mock(spec=Response) mocker.patch.object(response, 'ok', False) assert dsctl.handle_response(response, '') is False