def test_show_login(): """ The login dialog is displayed with a clean state. """ mock_controller = mock.MagicMock() w = Window() w.setup(mock_controller) with mock.patch('securedrop_client.gui.main.LoginDialog') as mock_ld: w.show_login() mock_ld.assert_called_once_with(w) w.login_dialog.reset.assert_called_once_with() w.login_dialog.exec.assert_called_once_with()
def test_show_login(mocker): """ The login dialog is displayed with a clean state. """ w = Window() w.controller = mocker.MagicMock() mock_ld = mocker.patch('securedrop_client.gui.main.LoginDialog') w.show_login() mock_ld.assert_called_once_with(w) w.login_dialog.reset.assert_called_once_with() w.login_dialog.show.assert_called_once_with()
def test_show_login_with_error_message(mocker): """ The login dialog is displayed with a clean state. """ w = Window() w.controller = mocker.MagicMock() mock_ld = mocker.patch('securedrop_client.gui.main.LoginDialog') w.show_login('this-is-an-error-message-to-show-on-login-window') mock_ld.assert_called_once_with(w) w.login_dialog.reset.assert_called_once_with() w.login_dialog.show.assert_called_once_with() w.login_dialog.error.assert_called_once_with('this-is-an-error-message-to-show-on-login-window')
def test_show_login_error(mocker): """ Ensures that an error message is displayed in the login dialog. """ w = Window() w.show_login = mocker.MagicMock() w.setup(mocker.MagicMock()) w.login_dialog = mocker.MagicMock() w.show_login_error('boom') w.login_dialog.error.assert_called_once_with('boom')
def test_hide_login(mocker): """ Ensure the login dialog is closed and hidden. """ w = Window() w.show_login = mocker.MagicMock() ld = mocker.MagicMock() w.login_dialog = ld w.hide_login() ld.accept.assert_called_once_with() assert w.login_dialog is None
def test_setup(mocker): """ Ensure the passed in controller is referenced and the various views are instantiated as expected. """ w = Window() mock_controller = mocker.MagicMock() w.show_login = mocker.MagicMock() w.top_pane = mocker.MagicMock() w.left_pane = mocker.MagicMock() w.main_view = mocker.MagicMock() w.setup(mock_controller) assert w.controller == mock_controller w.top_pane.setup.assert_called_once_with(mock_controller) w.left_pane.setup.assert_called_once_with(w, mock_controller) w.main_view.setup.assert_called_once_with(mock_controller) w.show_login.assert_called_once_with()