From ad42a714277c578747072d246e5dbab04a76204c Mon Sep 17 00:00:00 2001 From: Veronica Berglyd Olsen <1619840+vkbo@users.noreply.github.com> Date: Sat, 21 May 2022 16:57:09 +0200 Subject: [PATCH] Fix tests --- novelwriter/core/project.py | 37 ++++---- .../coreProject_NewCustomA_nwProject.nwx | 92 ++++++++----------- .../coreProject_NewCustomB_nwProject.nwx | 64 ++++++------- tests/test_core/test_core_project.py | 14 +-- tests/test_tools/test_tools_projwizard.py | 14 +-- 5 files changed, 96 insertions(+), 125 deletions(-) diff --git a/novelwriter/core/project.py b/novelwriter/core/project.py index fa0bddc9..d193b4eb 100644 --- a/novelwriter/core/project.py +++ b/novelwriter/core/project.py @@ -295,27 +295,9 @@ class NWProject(): # and a number of chapters and scenes selected in the # wizard's custom page. - noteTitles = { - nwItemClass.PLOT: self.tr("Main Plot"), - nwItemClass.CHARACTER: self.tr("Protagonist"), - nwItemClass.WORLD: self.tr("Main Location"), - } - - # Create root folders + # Create novel folders nHandle = self.newRoot(self.tr("Novel"), nwItemClass.NOVEL) - addNotes = projData.get("addNotes", False) - for newRoot in projData.get("addRoots", []): - if newRoot in nwItemClass: - rHandle = self.newRoot(nwLabels.CLASS_NAME[newRoot], newRoot) - if addNotes: - aHandle = self.newFile(noteTitles[newRoot], rHandle) - ntTag = simplified(noteTitles[newRoot]).replace(" ", "") - aDoc = NWDoc(self, aHandle) - aDoc.writeDocument(f"# {noteTitles[newRoot]}\n\n@tag: {ntTag}\n\n") - - # Create a title page tHandle = self.newFile(self.tr("Title Page"), nHandle) - aDoc = NWDoc(self, tHandle) aDoc.writeDocument(titlePage) @@ -350,6 +332,23 @@ class NWProject(): aDoc = NWDoc(self, sHandle) aDoc.writeDocument(f"### {scTitle}\n\n% Synopsis: {scSynop}\n\n") + # Create notes folders + noteTitles = { + nwItemClass.PLOT: self.tr("Main Plot"), + nwItemClass.CHARACTER: self.tr("Protagonist"), + nwItemClass.WORLD: self.tr("Main Location"), + } + + addNotes = projData.get("addNotes", False) + for newRoot in projData.get("addRoots", []): + if newRoot in nwItemClass: + rHandle = self.newRoot(nwLabels.CLASS_NAME[newRoot], newRoot) + if addNotes: + aHandle = self.newFile(noteTitles[newRoot], rHandle) + ntTag = simplified(noteTitles[newRoot]).replace(" ", "") + aDoc = NWDoc(self, aHandle) + aDoc.writeDocument(f"# {noteTitles[newRoot]}\n\n@tag: {ntTag}\n\n") + # Finalise if popCustom or popMinimal: self.projOpened = time() diff --git a/tests/reference/coreProject_NewCustomA_nwProject.nwx b/tests/reference/coreProject_NewCustomA_nwProject.nwx index 14abf9e2..4e201ccd 100644 --- a/tests/reference/coreProject_NewCustomA_nwProject.nwx +++ b/tests/reference/coreProject_NewCustomA_nwProject.nwx @@ -1,5 +1,5 @@ - + Test Custom Test Novel @@ -29,7 +29,7 @@
- New + New Note Draft Finished @@ -41,98 +41,86 @@ Main - + Novel - - - Plot - - - - Characters - - - - Locations - - - - Timeline - - - - Objects - - - - Entities - - + Title Page - - - Chapter 1 - - + Chapter 1 - + Scene 1.1 - + Scene 1.2 - + Scene 1.3 - - - Chapter 2 - - + Chapter 2 - + Scene 2.1 - + Scene 2.2 - + Scene 2.3 - - - Chapter 3 - - + Chapter 3 - + Scene 3.1 - + Scene 3.2 - + Scene 3.3 + + + Plot + + + + Main Plot + + + + Characters + + + + Protagonist + + + + Locations + + + + Main Location +
diff --git a/tests/reference/coreProject_NewCustomB_nwProject.nwx b/tests/reference/coreProject_NewCustomB_nwProject.nwx index bca6ea80..6b45cbbc 100644 --- a/tests/reference/coreProject_NewCustomB_nwProject.nwx +++ b/tests/reference/coreProject_NewCustomB_nwProject.nwx @@ -1,5 +1,5 @@ - + Test Custom Test Novel @@ -46,57 +46,57 @@ Novel - - - Plot - - - - Characters - - - - Locations - - - - Timeline - - - - Objects - - - - Entities - - + Title Page - + Scene 1 - + Scene 2 - + Scene 3 - + Scene 4 - + Scene 5 - + Scene 6 + + + Plot + + + + Main Plot + + + + Characters + + + + Protagonist + + + + Locations + + + + Main Location + diff --git a/tests/test_core/test_core_project.py b/tests/test_core/test_core_project.py index 55c18e65..5162e0b9 100644 --- a/tests/test_core/test_core_project.py +++ b/tests/test_core/test_core_project.py @@ -103,13 +103,10 @@ def testCoreProject_NewCustomA(fncDir, outDir, refDir, mockGUI, mockRnd): nwItemClass.PLOT, nwItemClass.CHARACTER, nwItemClass.WORLD, - nwItemClass.TIMELINE, - nwItemClass.OBJECT, - nwItemClass.ENTITY, ], + "addNotes": True, "numChapters": 3, "numScenes": 3, - "chFolders": True, } theProject = NWProject(mockGUI) @@ -144,13 +141,10 @@ def testCoreProject_NewCustomB(fncDir, outDir, refDir, mockGUI, mockRnd): nwItemClass.PLOT, nwItemClass.CHARACTER, nwItemClass.WORLD, - nwItemClass.TIMELINE, - nwItemClass.OBJECT, - nwItemClass.ENTITY, ], + "addNotes": True, "numChapters": 0, "numScenes": 6, - "chFolders": True, } theProject = NWProject(mockGUI) @@ -1178,10 +1172,6 @@ def testCoreProject_LegacyData(monkeypatch, mockGUI, fncDir): theProject = NWProject(mockGUI) theProject.setProjectPath(fncDir) - # assert theProject.newProject({"projPath": fncDir}) - # assert theProject.saveProject() - # assert theProject.closeProject() - # Check behaviour of deprecated files function on OSError tstFile = os.path.join(fncDir, "ToC.json") writeFile(tstFile, "stuff") diff --git a/tests/test_tools/test_tools_projwizard.py b/tests/test_tools/test_tools_projwizard.py index ef4c31cd..8839964e 100644 --- a/tests/test_tools/test_tools_projwizard.py +++ b/tests/test_tools/test_tools_projwizard.py @@ -205,14 +205,11 @@ def testToolProjectWizard_Run(qtbot, monkeypatch, nwGUI, fncDir, prjType): customPage.addPlot.setChecked(True) customPage.addChar.setChecked(True) customPage.addWorld.setChecked(True) - customPage.addTime.setChecked(True) - customPage.addObject.setChecked(True) - customPage.addEntity.setChecked(True) + customPage.addNotes.setChecked(True) if prjType == "custom2": customPage.numChapters.setValue(0) customPage.numScenes.setValue(10) - customPage.chFolders.setChecked(False) qtbot.wait(stepDelay) qtbot.mouseClick(nwWiz.button(QWizard.NextButton), Qt.LeftButton) @@ -240,23 +237,20 @@ def testToolProjectWizard_Run(qtbot, monkeypatch, nwGUI, fncDir, prjType): nwItemClass.PLOT, nwItemClass.CHARACTER, nwItemClass.WORLD, - nwItemClass.TIMELINE, - nwItemClass.OBJECT, - nwItemClass.ENTITY, ] if prjType == "custom1": assert projData["numChapters"] == 5 assert projData["numScenes"] == 5 - assert projData["chFolders"] + assert projData["addNotes"] is True else: assert projData["numChapters"] == 0 assert projData["numScenes"] == 10 - assert not projData["chFolders"] + assert projData["addNotes"] is True else: assert projData["addRoots"] == [] assert projData["numChapters"] == 0 assert projData["numScenes"] == 0 - assert not projData["chFolders"] + assert projData["addNotes"] is False # Cleanup nwWiz.reject()