From bf35bda9429e69af26491b535c765b6241c8751f Mon Sep 17 00:00:00 2001 From: "Veronica K. B. Olsen" <1619840+vkbo@users.noreply.github.com> Date: Sun, 9 Aug 2020 20:53:38 +0200 Subject: [PATCH] Fixed tests --- nw/guimain.py | 19 +++++++++++-------- tests/test_gui.py | 6 +++--- tests/test_project.py | 2 +- 3 files changed, 15 insertions(+), 12 deletions(-) diff --git a/nw/guimain.py b/nw/guimain.py index 00778aba..0a67ccfb 100644 --- a/nw/guimain.py +++ b/nw/guimain.py @@ -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: diff --git a/tests/test_gui.py b/tests/test_gui.py index 7660497f..d8e6628b 100644 --- a/tests/test_gui.py +++ b/tests/test_gui.py @@ -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") diff --git a/tests/test_project.py b/tests/test_project.py index a4ae401e..9baa2c4b 100644 --- a/tests/test_project.py +++ b/tests/test_project.py @@ -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()