Add some more easy coverage
This commit is contained in:
+4
-14
@@ -304,9 +304,6 @@ class GuiMain(QMainWindow):
|
||||
self.keyEscape.setKey(Qt.Key.Key_Escape)
|
||||
self.keyEscape.activated.connect(self._keyPressEscape)
|
||||
|
||||
# Check that config loaded fine
|
||||
self.reportConfErr()
|
||||
|
||||
# Initialise Main GUI
|
||||
self.initMain()
|
||||
self.asProjTimer.start()
|
||||
@@ -328,6 +325,10 @@ class GuiMain(QMainWindow):
|
||||
|
||||
def postLaunchTasks(self, cmdOpen: str | None) -> None:
|
||||
"""Process tasks after the main window has been created."""
|
||||
# Check that config loaded fine
|
||||
if CONFIG.hasError:
|
||||
SHARED.error(CONFIG.errorText())
|
||||
|
||||
if cmdOpen:
|
||||
QApplication.processEvents()
|
||||
logger.info("Command line path: %s", cmdOpen)
|
||||
@@ -843,15 +844,6 @@ class GuiMain(QMainWindow):
|
||||
SHARED.error(self.tr("Could not initialise the dialog."))
|
||||
return
|
||||
|
||||
def reportConfErr(self) -> None:
|
||||
"""Checks if the Config module has any errors to report, and let
|
||||
the user know if this is the case. The Config module caches
|
||||
errors since it is initialised before the GUI itself.
|
||||
"""
|
||||
if CONFIG.hasError:
|
||||
SHARED.error(CONFIG.errorText())
|
||||
return
|
||||
|
||||
##
|
||||
# Main Window Actions
|
||||
##
|
||||
@@ -882,9 +874,7 @@ class GuiMain(QMainWindow):
|
||||
|
||||
if SHARED.hasProject:
|
||||
self.closeProject(True)
|
||||
|
||||
CONFIG.saveConfig()
|
||||
self.reportConfErr()
|
||||
|
||||
QApplication.quit()
|
||||
|
||||
|
||||
@@ -84,6 +84,10 @@ def testGuiMain_Launch(qtbot, monkeypatch, nwGUI, projPath):
|
||||
# Check that latest release info updated
|
||||
assert CONFIG.lastNotes != "0x0"
|
||||
|
||||
# Set some config error
|
||||
CONFIG._hasError = True
|
||||
CONFIG._errData.append("Foo")
|
||||
|
||||
# Check that project open dialog launches
|
||||
nwGUI.postLaunchTasks(None)
|
||||
qtbot.waitUntil(lambda: SHARED.findTopLevelWidget(GuiWelcome) is not None, timeout=1000)
|
||||
@@ -91,6 +95,10 @@ def testGuiMain_Launch(qtbot, monkeypatch, nwGUI, projPath):
|
||||
welcome.show()
|
||||
welcome.close()
|
||||
|
||||
# Config errors should be cleared
|
||||
assert SHARED.lastAlert == "Foo"
|
||||
assert CONFIG._hasError is False
|
||||
|
||||
# qtbot.stop()
|
||||
|
||||
|
||||
@@ -578,7 +586,11 @@ def testGuiMain_Viewing(qtbot, monkeypatch, nwGUI, projPath, mockRnd):
|
||||
assert nwGUI.viewDocument(None) is False
|
||||
assert nwGUI.splitView.isVisible() is False
|
||||
|
||||
# Open the test project
|
||||
# Open project requires a path
|
||||
assert nwGUI.openProject(None) is False
|
||||
assert SHARED.hasProject is False
|
||||
|
||||
# Open the test project, properly
|
||||
nwGUI.openProject(projPath)
|
||||
assert nwGUI.docEditor.docHandle == C.hTitlePage
|
||||
|
||||
|
||||
Reference in New Issue
Block a user