Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix up some tests that were broken during codecamp #2326

Merged
merged 2 commits into from
Oct 29, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions src/sas/qtgui/MainWindow/UnitTesting/GuiManagerTest.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
from sas.qtgui.MainWindow.AboutBox import AboutBox
from sas.qtgui.MainWindow.WelcomePanel import WelcomePanel
from sas.qtgui.Utilities.IPythonWidget import IPythonWidget
from sas.qtgui.Utilities.HidableDialog import HidableDialog

from sas.qtgui.MainWindow.GuiManager import Acknowledgements, GuiManager
from sas.qtgui.MainWindow.MainWindow import MainSasViewWindow
Expand Down Expand Up @@ -122,22 +123,22 @@ def testQuitApplication(self, manager, mocker):
mocker.patch.object(sys, 'exit')

# Say No to the close dialog
mocker.patch.object(QMessageBox, 'question', return_value=QMessageBox.No)
mocker.patch.object(HidableDialog, 'exec', return_value=False)

# Open, then close the manager
manager.quitApplication()

# See that the MessageBox method got called
#assert QMessageBox.question.called
# See that the HidableDialog.exec method got called
assert HidableDialog.exec.called

# Say Yes to the close dialog
mocker.patch.object(QMessageBox, 'question', return_value=QMessageBox.Yes)
mocker.patch.object(HidableDialog, 'exec', return_value=True)

# Open, then close the manager
manager.quitApplication()

# See that the MessageBox method got called
#assert QMessageBox.question.called
# See that the HidableDialog.exec method got called
assert HidableDialog.exec.called

@pytest.mark.xfail(reason="2022-09 already broken")
def testCheckUpdate(self, manager, mocker):
Expand Down
5 changes: 3 additions & 2 deletions src/sas/qtgui/MainWindow/UnitTesting/MainWindowTest.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
from sas.qtgui.MainWindow.MainWindow import MainSasViewWindow
from sas.qtgui.MainWindow.MainWindow import SplashScreen
from sas.qtgui.Perspectives.Fitting import FittingPerspective
from sas.qtgui.Utilities.HidableDialog import HidableDialog


class MainWindowTest:
Expand Down Expand Up @@ -98,12 +99,12 @@ def testExit(self, qapp, mocker):
"""
# Must mask sys.exit, otherwise the whole testing process stops.
mocker.patch.object(sys, 'exit')
mocker.patch.object(QtWidgets.QMessageBox, 'question', return_value=QtWidgets.QMessageBox.Yes)
mocker.patch.object(HidableDialog, 'exec', return_value=True)

# Open, then close the main window
screen_resolution = QtCore.QRect(0, 0, 640, 480)
tmp_main = MainSasViewWindow(screen_resolution, None)
tmp_main.close()

# See that the MessageBox method got called
assert QtWidgets.QMessageBox.question.called
assert HidableDialog.exec.called
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def data(self):
def testDefaults(self, widget):
"""Test the freshly-opened panel with no changes made"""
assert widget.stackedWidget.count() == widget.listWidget.count()
assert -1 == widget.stackedWidget.currentIndex()
assert 0 == widget.stackedWidget.currentIndex()

def testPreferencesInteractions(self, widget):
"""Test the base interactions in window behavior"""
Expand Down