From 999732efdfb72acd9e913888e38cd5474d75709d Mon Sep 17 00:00:00 2001 From: bigtedde Date: Wed, 30 Aug 2023 15:29:17 -0700 Subject: [PATCH] fixed bug in ssh combo box refresh --- src/vorta/views/repo_tab.py | 3 +-- tests/unit/test_repo.py | 8 ++++---- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/src/vorta/views/repo_tab.py b/src/vorta/views/repo_tab.py index 96b614b02..906f63f49 100644 --- a/src/vorta/views/repo_tab.py +++ b/src/vorta/views/repo_tab.py @@ -198,8 +198,7 @@ def create_ssh_key(self): ssh_add_window = SSHAddWindow() self._window = ssh_add_window # For tests ssh_add_window.setParent(self, QtCore.Qt.WindowType.Sheet) - ssh_add_window.accepted.connect(self.init_ssh) - # ssh_add_window.rejected.connect(lambda: self.sshComboBox.setCurrentIndex(0)) + ssh_add_window.rejected.connect(self.init_ssh) ssh_add_window.open() def ssh_copy_to_clipboard_action(self): diff --git a/tests/unit/test_repo.py b/tests/unit/test_repo.py index 9a32f50b4..a5f723415 100644 --- a/tests/unit/test_repo.py +++ b/tests/unit/test_repo.py @@ -5,7 +5,7 @@ import pytest import vorta.borg.borg_job from PyQt6 import QtCore -from PyQt6.QtWidgets import QMessageBox +from PyQt6.QtWidgets import QDialogButtonBox, QMessageBox from vorta.keyring.abc import VortaKeyring from vorta.store.models import ArchiveModel, EventLogModel, RepoModel @@ -243,10 +243,10 @@ def test_ssh_copy_to_clipboard_action(qapp, qtbot, mocker, tmpdir): key_tmpfile, pub_tmpfile = ssh_dir.join("id_rsa-test"), ssh_dir.join("id_rsa-test.pub") # noqa: F841 key_tmpfile_full = os.path.join(key_tmpfile.dirname, key_tmpfile.basename) ssh_dialog.outputFileTextBox.setText(key_tmpfile_full) - ssh_dialog.generate_key() + qtbot.mouseClick(ssh_dialog.generateButton, QtCore.Qt.MouseButton.LeftButton) qtbot.waitUntil(lambda: ssh_dialog.errors.text().startswith('New key was copied'), **pytest._wait_defaults) - assert len(ssh_dir.listdir()) == 2 - assert tab.sshComboBox.count() > 1 + cancel_button = ssh_dialog.buttonBox.button(QDialogButtonBox.StandardButton.Cancel) + qtbot.mouseClick(cancel_button, QtCore.Qt.MouseButton.LeftButton) # no ssh key selected to copy assert tab.sshComboBox.currentIndex() == 0