From ebee9ff791b5bc385ebace92176f8b32c5b17ca2 Mon Sep 17 00:00:00 2001 From: Veronica Berglyd Olsen <1619840+vkbo@users.noreply.github.com> Date: Sat, 16 Apr 2022 20:56:52 +0200 Subject: [PATCH] Update tests --- .../coreProject_NewCustomA_nwProject.nwx | 50 +++++++++---------- .../coreProject_NewCustomB_nwProject.nwx | 32 ++++++------ .../coreProject_NewFile_nwProject.nwx | 8 +-- .../coreProject_NewRoot_nwProject.nwx | 20 ++++---- .../guiEditor_Main_Final_nwProject.nwx | 12 ++--- .../guiEditor_Main_Initial_nwProject.nwx | 18 +++---- .../guiProjSettings_Dialog_nwProject.nwx | 20 ++++---- tests/test_core/test_core_document.py | 2 +- tests/test_core/test_core_index.py | 30 +++++------ tests/test_core/test_core_project.py | 10 ++-- tests/test_core/test_core_tree.py | 26 +++++----- tests/test_gui/test_gui_doceditor.py | 4 +- tests/test_gui/test_gui_statusbar.py | 4 +- 13 files changed, 119 insertions(+), 117 deletions(-) diff --git a/tests/reference/coreProject_NewCustomA_nwProject.nwx b/tests/reference/coreProject_NewCustomA_nwProject.nwx index 2651909c..9152e3b6 100644 --- a/tests/reference/coreProject_NewCustomA_nwProject.nwx +++ b/tests/reference/coreProject_NewCustomA_nwProject.nwx @@ -1,5 +1,5 @@ - + Test Custom Test Novel @@ -35,7 +35,7 @@ Finished - New + New Minor Major Main @@ -44,95 +44,95 @@ - Novel + Novel - Plot + Plot - Characters + Characters - Locations + Locations - Timeline + Timeline - Objects + Objects - Entities + Entities - Title Page + Title Page - Chapter 1 + Chapter 1 - Chapter 1 + Chapter 1 - Scene 1.1 + Scene 1.1 - Scene 1.2 + Scene 1.2 - Scene 1.3 + Scene 1.3 - Chapter 2 + Chapter 2 - Chapter 2 + Chapter 2 - Scene 2.1 + Scene 2.1 - Scene 2.2 + Scene 2.2 - Scene 2.3 + Scene 2.3 - Chapter 3 + Chapter 3 - Chapter 3 + Chapter 3 - Scene 3.1 + Scene 3.1 - Scene 3.2 + Scene 3.2 - Scene 3.3 + Scene 3.3 diff --git a/tests/reference/coreProject_NewCustomB_nwProject.nwx b/tests/reference/coreProject_NewCustomB_nwProject.nwx index 7ca8751d..ef29585b 100644 --- a/tests/reference/coreProject_NewCustomB_nwProject.nwx +++ b/tests/reference/coreProject_NewCustomB_nwProject.nwx @@ -1,5 +1,5 @@ - + Test Custom Test Novel @@ -35,7 +35,7 @@ Finished - New + New Minor Major Main @@ -44,59 +44,59 @@ - Novel + Novel - Plot + Plot - Characters + Characters - Locations + Locations - Timeline + Timeline - Objects + Objects - Entities + Entities - Title Page + Title Page - Scene 1 + Scene 1 - Scene 2 + Scene 2 - Scene 3 + Scene 3 - Scene 4 + Scene 4 - Scene 5 + Scene 5 - Scene 6 + Scene 6 diff --git a/tests/reference/coreProject_NewFile_nwProject.nwx b/tests/reference/coreProject_NewFile_nwProject.nwx index a1c33b58..13fd7966 100644 --- a/tests/reference/coreProject_NewFile_nwProject.nwx +++ b/tests/reference/coreProject_NewFile_nwProject.nwx @@ -1,5 +1,5 @@ - + New Project @@ -33,7 +33,7 @@ Finished - New + New Minor Major Main @@ -74,11 +74,11 @@ - Hello + Hello - Jane + Jane diff --git a/tests/reference/coreProject_NewRoot_nwProject.nwx b/tests/reference/coreProject_NewRoot_nwProject.nwx index 4274814c..264cfa0f 100644 --- a/tests/reference/coreProject_NewRoot_nwProject.nwx +++ b/tests/reference/coreProject_NewRoot_nwProject.nwx @@ -1,5 +1,5 @@ - + New Project @@ -33,7 +33,7 @@ Finished - New + New Minor Major Main @@ -74,35 +74,35 @@ - Novel + Novel - Plot + Plot - Character + Character - World + World - Timeline + Timeline - Object + Object - Custom1 + Custom1 - Custom2 + Custom2 diff --git a/tests/reference/guiEditor_Main_Final_nwProject.nwx b/tests/reference/guiEditor_Main_Final_nwProject.nwx index 84515134..64ed4b4f 100644 --- a/tests/reference/guiEditor_Main_Final_nwProject.nwx +++ b/tests/reference/guiEditor_Main_Final_nwProject.nwx @@ -1,5 +1,5 @@ - + New Project @@ -33,7 +33,7 @@ Finished - New + New Minor Major Main @@ -66,7 +66,7 @@ - New File + New File @@ -74,7 +74,7 @@ - New File + New File @@ -82,11 +82,11 @@ - New File + New File - Trash + Trash diff --git a/tests/reference/guiEditor_Main_Initial_nwProject.nwx b/tests/reference/guiEditor_Main_Initial_nwProject.nwx index 8ed179b3..d6c8b904 100644 --- a/tests/reference/guiEditor_Main_Initial_nwProject.nwx +++ b/tests/reference/guiEditor_Main_Initial_nwProject.nwx @@ -33,7 +33,7 @@ Finished - New + New Minor Major Main @@ -42,35 +42,35 @@ - Novel + Novel - Title Page + Title Page - New Chapter + New Chapter - New Chapter + New Chapter - New Scene + New Scene - Plot + Plot - Characters + Characters - World + World diff --git a/tests/reference/guiProjSettings_Dialog_nwProject.nwx b/tests/reference/guiProjSettings_Dialog_nwProject.nwx index b74533d4..6c4cefdb 100644 --- a/tests/reference/guiProjSettings_Dialog_nwProject.nwx +++ b/tests/reference/guiProjSettings_Dialog_nwProject.nwx @@ -1,5 +1,5 @@ - + Project Name Project Title @@ -39,7 +39,7 @@ Final - New + New Minor Major Final @@ -48,35 +48,35 @@ - Novel + Novel - Title Page + Title Page - New Chapter + New Chapter - New Chapter + New Chapter - New Scene + New Scene - Plot + Plot - Characters + Characters - World + World diff --git a/tests/test_core/test_core_document.py b/tests/test_core/test_core_document.py index eb7794b5..881290d6 100644 --- a/tests/test_core/test_core_document.py +++ b/tests/test_core/test_core_document.py @@ -66,7 +66,7 @@ def testCoreDocument_LoadSave(monkeypatch, mockGUI, nwMinimal): # Try to open a new (non-existent) file nHandle = theProject.projTree.findRoot(nwItemClass.NOVEL) assert nHandle is not None - xHandle = theProject.newFile("New File", nwItemClass.NOVEL, nHandle) + xHandle = theProject.newFile("New File", nHandle) theDoc = NWDoc(theProject, xHandle) assert bool(theDoc) is True assert repr(theDoc) == f"" diff --git a/tests/test_core/test_core_index.py b/tests/test_core/test_core_index.py index 8070cbf2..cf7b1687 100644 --- a/tests/test_core/test_core_index.py +++ b/tests/test_core/test_core_index.py @@ -181,8 +181,8 @@ def testCoreIndex_CheckThese(nwMinimal, mockGUI): assert theProject.openProject(nwMinimal) is True theIndex = NWIndex(theProject) - nHandle = theProject.newFile("Hello", nwItemClass.NOVEL, "a508bb932959c") - cHandle = theProject.newFile("Jane", nwItemClass.CHARACTER, "afb3043c7b2b3") + nHandle = theProject.newFile("Hello", "a508bb932959c") + cHandle = theProject.newFile("Jane", "afb3043c7b2b3") nItem = theProject.projTree[nHandle] cItem = theProject.projTree[cHandle] @@ -260,8 +260,8 @@ def testCoreIndex_ScanText(nwMinimal, mockGUI): theIndex = NWIndex(theProject) # Some items for fail to scan tests - dHandle = theProject.newFolder("Folder", nwItemClass.NOVEL, "a508bb932959c") - xHandle = theProject.newFile("No Layout", nwItemClass.NOVEL, "a508bb932959c") + dHandle = theProject.newFolder("Folder", "a508bb932959c") + xHandle = theProject.newFile("No Layout", "a508bb932959c") xItem = theProject.projTree[xHandle] xItem.setLayout(nwItemLayout.NO_LAYOUT) @@ -279,6 +279,8 @@ def testCoreIndex_ScanText(nwMinimal, mockGUI): assert theProject.projTree[tHandle] is not None xItem.setParent(tHandle) theProject.projTree.updateItemData(xItem.itemHandle) + assert xItem.itemRoot == tHandle + assert xItem.itemClass == nwItemClass.TRASH assert theIndex.scanText(xHandle, "Hello World!") is False # Create the archive root @@ -289,11 +291,11 @@ def testCoreIndex_ScanText(nwMinimal, mockGUI): assert theIndex.scanText(xHandle, "Hello World!") is False # Make some usable items - tHandle = theProject.newFile("Title", nwItemClass.NOVEL, "a508bb932959c") - pHandle = theProject.newFile("Page", nwItemClass.NOVEL, "a508bb932959c") - nHandle = theProject.newFile("Hello", nwItemClass.NOVEL, "a508bb932959c") - cHandle = theProject.newFile("Jane", nwItemClass.CHARACTER, "afb3043c7b2b3") - sHandle = theProject.newFile("Scene", nwItemClass.NOVEL, "a508bb932959c") + tHandle = theProject.newFile("Title", "a508bb932959c") + pHandle = theProject.newFile("Page", "a508bb932959c") + nHandle = theProject.newFile("Hello", "a508bb932959c") + cHandle = theProject.newFile("Jane", "afb3043c7b2b3") + sHandle = theProject.newFile("Scene", "a508bb932959c") # Text Indexing # ============= @@ -475,8 +477,8 @@ def testCoreIndex_ExtractData(nwMinimal, mockGUI): assert theProject.openProject(nwMinimal) is True theIndex = NWIndex(theProject) - nHandle = theProject.newFile("Hello", nwItemClass.NOVEL, "a508bb932959c") - cHandle = theProject.newFile("Jane", nwItemClass.CHARACTER, "afb3043c7b2b3") + nHandle = theProject.newFile("Hello", "a508bb932959c") + cHandle = theProject.newFile("Jane", "afb3043c7b2b3") assert theIndex.getNovelData("", "") is None assert theIndex.getNovelData("a508bb932959c", "") is None @@ -630,9 +632,9 @@ def testCoreIndex_ExtractData(nwMinimal, mockGUI): # Novel Stats # =========== - hHandle = theProject.newFile("Chapter", nwItemClass.NOVEL, "a508bb932959c") - sHandle = theProject.newFile("Scene One", nwItemClass.NOVEL, "a508bb932959c") - tHandle = theProject.newFile("Scene Two", nwItemClass.NOVEL, "a508bb932959c") + hHandle = theProject.newFile("Chapter", "a508bb932959c") + sHandle = theProject.newFile("Scene One", "a508bb932959c") + tHandle = theProject.newFile("Scene Two", "a508bb932959c") theProject.projTree[hHandle].itemLayout == nwItemLayout.DOCUMENT theProject.projTree[sHandle].itemLayout == nwItemLayout.DOCUMENT diff --git a/tests/test_core/test_core_project.py b/tests/test_core/test_core_project.py index 30cb7f33..3d5b37f4 100644 --- a/tests/test_core/test_core_project.py +++ b/tests/test_core/test_core_project.py @@ -314,8 +314,8 @@ def testCoreProject_NewFile(fncDir, outDir, refDir, mockGUI): assert theProject.closeProject() is True assert theProject.openProject(projFile) is True - assert isinstance(theProject.newFile("Hello", nwItemClass.NOVEL, "31489056e0916"), str) - assert isinstance(theProject.newFile("Jane", nwItemClass.CHARACTER, "71ee45a3c0db9"), str) + assert isinstance(theProject.newFile("Hello", "31489056e0916"), str) + assert isinstance(theProject.newFile("Jane", "71ee45a3c0db9"), str) assert theProject.projChanged assert theProject.saveProject() is True assert theProject.closeProject() is True @@ -661,7 +661,7 @@ def testCoreProject_AccessItems(nwMinimal, mockGUI): theProject.projTree._treeOrder.append("01234567789abc") # Add an item with a non-existent parent - nHandle = theProject.newFile("Test File", nwItemClass.NOVEL, "a6d311a93600a") + nHandle = theProject.newFile("Test File", "a6d311a93600a") theProject.projTree[nHandle].setParent("cba9876543210") assert theProject.projTree[nHandle].itemParent == "cba9876543210" @@ -740,7 +740,7 @@ def testCoreProject_StatusImport(mockGUI, fncDir, constData): # Change Importance # ================= - fHandle = theProject.newFile("Jane Doe", nwItemClass.CHARACTER, "73475cb40a568") + fHandle = theProject.newFile("Jane Doe", "73475cb40a568") theProject.projTree[fHandle].setImport("Main") assert theProject.projTree[fHandle].itemImport == constData.importKeys[3] @@ -1069,7 +1069,7 @@ def testCoreProject_OrphanedFiles(mockGUI, nwLipsum): assert oItem.itemParent == "b3643d0f92e32" assert oItem.itemClass == nwItemClass.NOVEL assert oItem.itemType == nwItemType.FILE - assert oItem.itemLayout == nwItemLayout.NOTE + assert oItem.itemLayout == nwItemLayout.DOCUMENT assert theProject.saveProject(nwLipsum) assert theProject.closeProject() diff --git a/tests/test_core/test_core_tree.py b/tests/test_core/test_core_tree.py index 3fd07a43..343c4609 100644 --- a/tests/test_core/test_core_tree.py +++ b/tests/test_core/test_core_tree.py @@ -397,31 +397,31 @@ def testCoreTree_XMLPackUnpack(mockGUI, mockItems): b'' b'' b'Novel' - b'' + b'class="NOVEL">Novel' b'Act One' + b'type="FOLDER" class="NOVEL">Act One' b'Chapter One' b'Scene One' b'Outtakes' + b'class="ARCHIVE">Outtakes' b'Trash' - b'' + b'class="TRASH">Trash' b'Characters' + b'class="CHARACTER">Characters' b'Jane Doe' b'' b'' diff --git a/tests/test_gui/test_gui_doceditor.py b/tests/test_gui/test_gui_doceditor.py index eaa1d2ba..cf5c3cea 100644 --- a/tests/test_gui/test_gui_doceditor.py +++ b/tests/test_gui/test_gui_doceditor.py @@ -29,7 +29,7 @@ from PyQt5.QtWidgets import QAction, QMessageBox, qApp from novelwriter.gui.doceditor import GuiDocEditor from novelwriter.core import countWords -from novelwriter.enum import nwDocAction, nwDocInsert, nwItemClass, nwItemLayout +from novelwriter.enum import nwDocAction, nwDocInsert, nwItemLayout from novelwriter.constants import nwKeyWords, nwUnicode keyDelay = 2 @@ -1143,7 +1143,7 @@ def testGuiEditor_Tags(qtbot, monkeypatch, nwGUI, nwMinimal, ipsumText): # Create Character theText = "### Jane Doe\n\n@tag: Jane\n\n" + ipsumText[1] + "\n\n" - cHandle = nwGUI.theProject.newFile("Jane Doe", nwItemClass.CHARACTER, "afb3043c7b2b3") + cHandle = nwGUI.theProject.newFile("Jane Doe", "afb3043c7b2b3") assert nwGUI.openDocument(cHandle) is True assert nwGUI.docEditor.replaceText(theText) is True assert nwGUI.saveDocument() is True diff --git a/tests/test_gui/test_gui_statusbar.py b/tests/test_gui/test_gui_statusbar.py index 9d7c4efc..66329820 100644 --- a/tests/test_gui/test_gui_statusbar.py +++ b/tests/test_gui/test_gui_statusbar.py @@ -25,7 +25,7 @@ import pytest from PyQt5.QtWidgets import QMessageBox from novelwriter.core import NWDoc -from novelwriter.enum import nwItemClass, nwState +from novelwriter.enum import nwState @pytest.mark.gui @@ -36,7 +36,7 @@ def testGuiStatusBar_Main(qtbot, monkeypatch, nwGUI, fncProj): nwGUI.theProject.projTree.setSeed(42) assert nwGUI.newProject({"projPath": fncProj}) is True - cHandle = nwGUI.theProject.newFile("A Note", nwItemClass.CHARACTER, "71ee45a3c0db9") + cHandle = nwGUI.theProject.newFile("A Note", "71ee45a3c0db9") newDoc = NWDoc(nwGUI.theProject, cHandle) newDoc.writeDocument("# A Note\n\n") nwGUI.treeView.revealNewTreeItem(cHandle)