From 47df3eccc93b0a91e91d78971f8834f1802a5e89 Mon Sep 17 00:00:00 2001 From: Samuel Date: Thu, 29 Oct 2020 23:15:38 -0500 Subject: [PATCH] Add profile add/edit test cases (#695) --- tests/test_profile.py | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 tests/test_profile.py diff --git a/tests/test_profile.py b/tests/test_profile.py new file mode 100644 index 00000000..a50613dd --- /dev/null +++ b/tests/test_profile.py @@ -0,0 +1,29 @@ +from PyQt5 import QtCore +from PyQt5.QtWidgets import QDialogButtonBox + +from vorta.views.profile_add_edit_dialog import AddProfileWindow, EditProfileWindow +from vorta.models import BackupProfileModel + + +def test_profile_add(qapp, qtbot): + main = qapp.main_window + add_profile_window = AddProfileWindow(main) + qtbot.addWidget(add_profile_window) + + # Add a new profile + qtbot.keyClicks(add_profile_window.profileNameField, 'Test Profile') + qtbot.mouseClick(add_profile_window.buttonBox.button(QDialogButtonBox.Save), QtCore.Qt.LeftButton) + assert BackupProfileModel.get_or_none(name='Test Profile') is not None + + +def test_profile_edit(qapp, qtbot): + main = qapp.main_window + edit_profile_window = EditProfileWindow(main, rename_existing_id=main.profileSelector.currentData()) + qtbot.addWidget(edit_profile_window) + + # Edit profile name + edit_profile_window.profileNameField.setText("") + qtbot.keyClicks(edit_profile_window.profileNameField, 'Test Profile') + qtbot.mouseClick(edit_profile_window.buttonBox.button(QDialogButtonBox.Save), QtCore.Qt.LeftButton) + assert BackupProfileModel.get_or_none(name='Default') is None + assert BackupProfileModel.get_or_none(name='Test Profile') is not None