Move the hasProject logic into the shared class

This commit is contained in:
Veronica Berglyd Olsen
2023-08-13 19:23:32 +02:00
parent fd181b18a6
commit 8154293d92
8 changed files with 71 additions and 55 deletions
-7
View File
@@ -31,9 +31,6 @@ class MockGuiMain(QObject):
def __init__(self):
super().__init__()
self._project = None
self.hasProject = True
self.mainStatus = MockStatusBar()
self.projPath = ""
@@ -44,10 +41,6 @@ class MockGuiMain(QObject):
return
@property
def project(self):
return self._project
def postLaunchTasks(self, cmdOpen):
return
+3 -3
View File
@@ -27,7 +27,7 @@ from PyQt5.QtGui import QColor
from PyQt5.QtCore import Qt
from PyQt5.QtWidgets import QDialog, QAction, QColorDialog
from novelwriter import CONFIG
from novelwriter import CONFIG, SHARED
from novelwriter.enum import nwItemType
from novelwriter.dialogs.editlabel import GuiEditLabel
from novelwriter.dialogs.projsettings import GuiProjectSettings
@@ -50,8 +50,8 @@ def testDlgProjSettings_Dialog(qtbot, monkeypatch, nwGUI):
assert getGuiItem("GuiProjectSettings") is None
# Pretend we have a project
nwGUI.hasProject = True
nwGUI.project.data.setSpellLang("en")
SHARED.project._valid = True
SHARED.project.data.setSpellLang("en")
# Get the dialog object
nwGUI.mainMenu.aProjectSettings.activate(QAction.Trigger)
+2 -2
View File
@@ -30,7 +30,7 @@ from tools import (
from PyQt5.QtCore import Qt
from PyQt5.QtWidgets import QDialog, QMessageBox, QInputDialog
from novelwriter import CONFIG
from novelwriter import CONFIG, SHARED
from novelwriter.enum import nwItemType, nwView, nwWidget
from novelwriter.constants import nwFiles
from novelwriter.gui.outline import GuiOutlineView
@@ -113,7 +113,7 @@ def testGuiMain_NewProject(monkeypatch, nwGUI, projPath):
# Close project
with monkeypatch.context() as mp:
nwGUI.hasProject = True
SHARED.project._valid = True
mp.setattr(QMessageBox, "result", lambda *a: QMessageBox.No)
assert nwGUI.newProject(projData={"projPath": projPath}) is False
+1 -1
View File
@@ -204,9 +204,9 @@ def buildTestProject(obj, projPath):
project.session.startSession()
project.setProjectChanged(True)
project.saveProject(autoSave=True)
project._valid = True
if nwGUI is not None:
nwGUI.hasProject = True
nwGUI.rebuildTrees()
return