Minor/test fixes (#1150)

* Reorder asserts in test_ssh_dialog
* Prevent borg-check from running during tests
This commit is contained in:
Manu 2021-12-24 14:26:21 +04:00 committed by GitHub
parent 8b763a9af9
commit 0390a666e7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 7 deletions

View File

@ -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)

View File

@ -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)