def main_window_no_key(mocker, homedir): # Setup app = QApplication([]) gui = Window() app.setActiveWindow(gui) gui.show() controller = Controller("http://localhost", gui, mocker.MagicMock(), homedir, proxy=False) controller.qubes = False gui.setup(controller) # Create a source widget source_list = gui.main_view.source_list source = factory.Source(public_key=None) source_list.update([source]) # Create a file widget, message widget, and reply widget mocker.patch("securedrop_client.gui.widgets.humanize_filesize", return_value="100") mocker.patch( "securedrop_client.gui.SecureQLabel.get_elided_text", return_value="1-yellow-doc.gz.gpg" ) source.collection.append( [ factory.File(source=source, filename="1-yellow-doc.gz.gpg"), factory.Message(source=source, filename="2-yellow-msg.gpg"), factory.Reply(source=source, filename="3-yellow-reply.gpg"), ] ) source_list.setCurrentItem(source_list.item(0)) gui.main_view.on_source_changed() yield gui # Teardown gui.login_dialog.close() app.exit()
def modal_dialog(mocker, homedir): app = QApplication([]) gui = Window() gui.show() controller = Controller("http://localhost", gui, mocker.MagicMock(), homedir, proxy=False) controller.qubes = False gui.setup(controller) gui.login_dialog.close() app.setActiveWindow(gui) dialog = ModalDialog() yield dialog dialog.close() app.exit()
def export_dialog(mocker, homedir): app = QApplication([]) gui = Window() gui.show() controller = Controller("http://localhost", gui, mocker.MagicMock(), homedir, proxy=False) controller.qubes = False gui.setup(controller) gui.login_dialog.close() app.setActiveWindow(gui) dialog = ExportDialog(controller, "file_uuid", "file_name") dialog.show() yield dialog dialog.close() gui.close()
def test_show_main_window_without_username(mocker): w = Window() w.autosize_window = mocker.MagicMock() w.show = mocker.MagicMock() w.set_logged_in_as = mocker.MagicMock() w.show_main_window() w.autosize_window.assert_called_once_with() w.show.assert_called_once_with() w.set_logged_in_as.called is False
def test_show_main_window(mocker): w = Window() w.autosize_window = mocker.MagicMock() w.show = mocker.MagicMock() w.set_logged_in_as = mocker.MagicMock() w.show_main_window(username='******') w.autosize_window.assert_called_once_with() w.show.assert_called_once_with() w.set_logged_in_as.assert_called_once_with('test_username')