Ejemplo n.º 1
0
def test_Client_on_authenticate_failed():
    """
    If the server responds with a negative to the request to authenticate, make
    sure the user knows.
    """
    mock_gui = mock.MagicMock()
    mock_session = mock.MagicMock()
    cl = Client('http://localhost', mock_gui, mock_session)
    cl.on_authenticate(False)
    mock_gui.show_login_error.\
        assert_called_once_with(error='There was a problem logging in. Please '
                                'try again.')
Ejemplo n.º 2
0
def test_Client_on_authenticate_failed(safe_tmpdir):
    """
    If the server responds with a negative to the request to authenticate, make
    sure the user knows.
    """
    mock_gui = mock.MagicMock()
    mock_session = mock.MagicMock()
    cl = Client('http://localhost', mock_gui, mock_session, str(safe_tmpdir))
    result_data = 'false'
    cl.on_authenticate(result_data)
    mock_gui.show_login_error.\
        assert_called_once_with(error='There was a problem signing in. Please '
                                'verify your credentials and try again.')
Ejemplo n.º 3
0
def test_Client_on_authenticate_ok():
    """
    Ensure the client syncs when the user successfully logs in.
    """
    mock_gui = mock.MagicMock()
    mock_session = mock.MagicMock()
    cl = Client('http://localhost', mock_gui, mock_session)
    cl.sync_api = mock.MagicMock()
    cl.api = mock.MagicMock()
    cl.api.username = '******'
    cl.on_authenticate(True)
    cl.sync_api.assert_called_once_with()
    cl.gui.set_logged_in_as.assert_called_once_with('test')
def test_Client_on_authenticate_failed(homedir, config, mocker):
    """
    If the server responds with a negative to the request to authenticate, make
    sure the user knows.
    Using the `config` fixture to ensure the config is written to disk.
    """
    mock_gui = mocker.MagicMock()
    mock_session = mocker.MagicMock()
    cl = Client('http://localhost', mock_gui, mock_session, homedir)
    result_data = 'false'
    cl.on_authenticate(result_data)
    mock_gui.show_login_error.\
        assert_called_once_with(error='There was a problem signing in. Please '
                                'verify your credentials and try again.')
Ejemplo n.º 5
0
def test_Client_on_authenticate_ok(safe_tmpdir):
    """
    Ensure the client syncs when the user successfully logs in.
    """
    mock_gui = mock.MagicMock()
    mock_session = mock.MagicMock()
    cl = Client('http://localhost', mock_gui, mock_session, str(safe_tmpdir))
    cl.sync_api = mock.MagicMock()
    cl.api = mock.MagicMock()
    cl.api.username = '******'
    cl.on_authenticate(True)
    cl.sync_api.assert_called_once_with()
    cl.gui.set_logged_in_as.assert_called_once_with('test')
    # Error status bar should be cleared
    cl.gui.update_error_status.assert_called_once_with("")
def test_Client_on_authenticate_ok(homedir, config, mocker):
    """
    Ensure the client syncs when the user successfully logs in.
    Using the `config` fixture to ensure the config is written to disk.
    """
    mock_gui = mocker.MagicMock()
    mock_session = mocker.MagicMock()
    cl = Client('http://localhost', mock_gui, mock_session, homedir)
    cl.sync_api = mocker.MagicMock()
    cl.api = mocker.MagicMock()
    cl.start_message_thread = mocker.MagicMock()
    cl.start_reply_thread = mocker.MagicMock()
    cl.api.username = '******'
    cl.on_authenticate(True)
    cl.sync_api.assert_called_once_with()
    cl.start_message_thread.assert_called_once_with()
    cl.gui.set_logged_in_as.assert_called_once_with('test')
    # Error status bar should be cleared
    cl.gui.update_error_status.assert_called_once_with("")