From 0390a666e77c2dcf6e3adddb85ed9f484cb63fae Mon Sep 17 00:00:00 2001 From: Manu <3916435+m3nu@users.noreply.github.com> Date: Fri, 24 Dec 2021 14:26:21 +0400 Subject: [PATCH] Minor/test fixes (#1150) * Reorder asserts in test_ssh_dialog * Prevent borg-check from running during tests --- tests/conftest.py | 1 + tests/test_repo.py | 15 ++++++++------- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/tests/conftest.py b/tests/conftest.py index 2aeec091..5ec6c834 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -55,6 +55,7 @@ def init_db(qapp, qtbot, tmpdir_factory): default_profile.repo = new_repo.id default_profile.dont_run_on_metered_networks = False + default_profile.validation_on = False default_profile.save() test_archive = ArchiveModel(snapshot_id='99999', name='test-archive', time=dt(2000, 1, 1, 0, 0), repo=1) diff --git a/tests/test_repo.py b/tests/test_repo.py index 4cda33ef..4303fff1 100644 --- a/tests/test_repo.py +++ b/tests/test_repo.py @@ -117,14 +117,15 @@ def test_ssh_dialog(qapp, qtbot, tmpdir): ssh_dialog.outputFileTextBox.setText(key_tmpfile_full) ssh_dialog.generate_key() - qtbot.waitUntil(lambda: key_tmpfile.check(file=1), **pytest._wait_defaults) - qtbot.waitUntil(lambda: pub_tmpfile.check(file=1), **pytest._wait_defaults) - - key_tmpfile_content = key_tmpfile.read() - pub_tmpfile_content = pub_tmpfile.read() - assert key_tmpfile_content.startswith('-----BEGIN OPENSSH PRIVATE KEY-----') - assert pub_tmpfile_content.startswith('ssh-ed25519') + # Ensure new key files exist qtbot.waitUntil(lambda: ssh_dialog.errors.text().startswith('New key was copied'), **pytest._wait_defaults) + assert len(ssh_dir.listdir()) == 2 + + # Ensure valid keys were created + key_tmpfile_content = key_tmpfile.read() + assert key_tmpfile_content.startswith('-----BEGIN OPENSSH PRIVATE KEY-----') + pub_tmpfile_content = pub_tmpfile.read() + assert pub_tmpfile_content.startswith('ssh-ed25519') ssh_dialog.generate_key() qtbot.waitUntil(lambda: ssh_dialog.errors.text().startswith('Key file already'), **pytest._wait_defaults)