Example #1
0
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
Example #2
0
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
Example #3
0
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
Example #4
0
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