Fixed tests

This commit is contained in:
Veronica K. B. Olsen
2020-08-09 20:53:38 +02:00
parent 9044ab4c3f
commit bf35bda942
3 changed files with 15 additions and 12 deletions
+11 -8
View File
@@ -263,7 +263,7 @@ class GuiMain(QMainWindow):
return True
def newProject(self, projPath=None, forceNew=False):
def newProject(self, projData=None, forceNew=False):
"""Create new project with a few default files and folders.
The variable forceNew is used for testing.
"""
@@ -275,15 +275,18 @@ class GuiMain(QMainWindow):
)
return False
projData = {}
if projPath is None:
if projData is None and self.mainConf.showGUI:
projData = self.newProjectDialog()
if projData is None:
return False
if "projPath" in projData:
projPath = projData["projPath"]
if projPath is None:
if projData is None:
return False
projPath = None
if "projPath" in projData:
projPath = projData["projPath"]
if projPath is None or projData is None:
logger.error("No projData or projPath set")
return False
if path.isfile(path.join(projPath,self.theProject.projFile)) and not forceNew:
+3 -3
View File
@@ -27,7 +27,7 @@ def testMainWindows(qtbot, nwTempGUI, nwRef, nwTemp):
# Create new, save, close project
nwGUI.theProject.projTree.setSeed(42)
assert nwGUI.newProject(nwTempGUI, True)
assert nwGUI.newProject({"projPath": nwTempGUI}, True)
assert nwGUI.saveProject()
assert nwGUI.closeProject()
@@ -274,7 +274,7 @@ def testProjectEditor(qtbot, nwTempGUI, nwRef, nwTemp):
# Create new, save, open project
nwGUI.theProject.projTree.setSeed(42)
assert nwGUI.newProject(nwTempGUI, True)
assert nwGUI.newProject({"projPath": nwTempGUI}, True)
nwGUI.mainConf.backupPath = nwTempGUI
projEdit = GuiProjectSettings(nwGUI, nwGUI.theProject)
@@ -363,7 +363,7 @@ def testItemEditor(qtbot, nwTempGUI, nwRef, nwTemp):
# Create new, save, open project
nwGUI.theProject.projTree.setSeed(42)
assert nwGUI.newProject(nwTempGUI, True)
assert nwGUI.newProject({"projPath": nwTempGUI}, True)
assert nwGUI.openDocument("31489056e0916")
itemEdit = GuiItemEditor(nwGUI, nwGUI.theProject, "31489056e0916")
+1 -1
View File
@@ -26,7 +26,7 @@ def testProjectNew(nwTempProj,nwRef,nwTemp):
projFile = path.join(nwTempProj,"nwProject.nwx")
refFile = path.join(nwRef,"proj","1_nwProject.nwx")
assert theConf.initConfig(nwRef, nwTemp)
assert theProject.newProject()
assert theProject.newProject({"projPath": nwTempProj})
assert theProject.setProjectPath(nwTempProj)
assert theProject.saveProject()
assert theProject.closeProject()