Update tests

This commit is contained in:
Veronica Berglyd Olsen
2022-04-16 20:56:52 +02:00
parent 61f5425662
commit ebee9ff791
13 changed files with 119 additions and 117 deletions
+1 -1
View File
@@ -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"<NWDoc handle={xHandle}>"
+16 -14
View File
@@ -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
+5 -5
View File
@@ -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()
+13 -13
View File
@@ -397,31 +397,31 @@ def testCoreTree_XMLPackUnpack(mockGUI, mockItems):
b'<novelWriterXML>'
b'<content count="8">'
b'<item handle="a000000000001" parent="None" root="a000000000001" order="0" type="ROOT" '
b'class="NOVEL"><meta expanded="True"/><name status="None" import="None">Novel</name>'
b'</item>'
b'class="NOVEL"><meta expanded="True"/><name status="s43dac0" '
b'import="i6c52c4">Novel</name></item>'
b'<item handle="b000000000001" parent="a000000000001" root="a000000000001" order="0" '
b'type="FOLDER" class="NOVEL"><meta expanded="True"/><name status="None" '
b'import="None">Act One</name></item>'
b'type="FOLDER" class="NOVEL"><meta expanded="True"/><name status="s43dac0" '
b'import="i6c52c4">Act One</name></item>'
b'<item handle="c000000000001" parent="b000000000001" root="a000000000001" order="0" '
b'type="FILE" class="NOVEL" layout="DOCUMENT"><meta charCount="300" wordCount="50" '
b'paraCount="2" cursorPos="0"/><name status="None" import="None" '
b'paraCount="2" cursorPos="0"/><name status="s43dac0" import="i6c52c4" '
b'exported="True">Chapter One</name></item>'
b'<item handle="c000000000002" parent="b000000000001" root="a000000000001" order="0" '
b'type="FILE" class="NOVEL" layout="DOCUMENT"><meta charCount="3000" wordCount="500" '
b'paraCount="20" cursorPos="0"/><name status="None" import="None" '
b'paraCount="20" cursorPos="0"/><name status="s43dac0" import="i6c52c4" '
b'exported="True">Scene One</name></item>'
b'<item handle="a000000000002" parent="None" root="a000000000002" order="0" type="ROOT" '
b'class="ARCHIVE"><meta expanded="False"/><name status="None" '
b'import="None">Outtakes</name></item>'
b'class="ARCHIVE"><meta expanded="False"/><name status="s43dac0" '
b'import="i6c52c4">Outtakes</name></item>'
b'<item handle="a000000000003" parent="None" root="a000000000003" order="0" type="TRASH" '
b'class="TRASH"><meta expanded="False"/><name status="None" import="None">Trash</name>'
b'</item>'
b'class="TRASH"><meta expanded="False"/><name status="s43dac0" '
b'import="i6c52c4">Trash</name></item>'
b'<item handle="a000000000004" parent="None" root="a000000000004" order="0" type="ROOT" '
b'class="CHARACTER"><meta expanded="True"/><name status="None" '
b'import="None">Characters</name></item>'
b'class="CHARACTER"><meta expanded="True"/><name status="s43dac0" '
b'import="i6c52c4">Characters</name></item>'
b'<item handle="b000000000002" parent="a000000000004" root="a000000000004" order="0" '
b'type="FILE" class="CHARACTER" layout="NOTE"><meta charCount="2000" wordCount="400" '
b'paraCount="16" cursorPos="0"/><name status="None" import="None" '
b'paraCount="16" cursorPos="0"/><name status="s43dac0" import="i6c52c4" '
b'exported="True">Jane Doe</name></item>'
b'</content>'
b'</novelWriterXML>'