Fix most tests with minor issues
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
<?xml version='1.0' encoding='utf-8'?>
|
||||
<novelWriterXML appVersion="2.6a3" hexVersion="0x020600a3" fileVersion="1.5" fileRevision="4" timeStamp="2024-10-28 18:19:29">
|
||||
<project id="5ac0df12-8b8b-476b-9905-21d33685687c" saveCount="50" autoCount="29" editTime="2448">
|
||||
<novelWriterXML appVersion="2.6b1" hexVersion="0x020600b1" fileVersion="1.5" fileRevision="4" timeStamp="2024-11-20 19:22:22">
|
||||
<project id="5ac0df12-8b8b-476b-9905-21d33685687c" saveCount="51" autoCount="29" editTime="2456">
|
||||
<name>Lorem Ipsum</name>
|
||||
<author>lipsum.com</author>
|
||||
</project>
|
||||
@@ -25,13 +25,13 @@
|
||||
<entry key="sedd043" count="7" red="50" green="200" blue="0" shape="SQUARE">Finished</entry>
|
||||
</status>
|
||||
<importance>
|
||||
<entry key="i613591" count="6" red="100" green="100" blue="100" shape="SQUARE">New</entry>
|
||||
<entry key="i613591" count="7" red="100" green="100" blue="100" shape="SQUARE">New</entry>
|
||||
<entry key="i560cbf" count="0" red="200" green="50" blue="0" shape="SQUARE">Minor</entry>
|
||||
<entry key="i37861c" count="0" red="200" green="150" blue="0" shape="SQUARE">Major</entry>
|
||||
<entry key="id6b1d0" count="0" red="50" green="200" blue="0" shape="SQUARE">Main</entry>
|
||||
</importance>
|
||||
</settings>
|
||||
<content items="21" novelWords="3115" notesWords="738">
|
||||
<content items="22" novelWords="3115" notesWords="738">
|
||||
<item handle="b3643d0f92e32" parent="None" root="b3643d0f92e32" order="0" type="ROOT" class="NOVEL">
|
||||
<meta expanded="yes" />
|
||||
<name status="sbaa94f" import="i613591">Novel</name>
|
||||
@@ -116,5 +116,9 @@
|
||||
<meta expanded="no" heading="H1" charCount="1770" wordCount="259" paraCount="3" cursorPos="47" />
|
||||
<name status="sbaa94f" import="i613591" active="yes">Ancient Europe</name>
|
||||
</item>
|
||||
<item handle="1ace7ab1a0fc6" parent="None" root="1ace7ab1a0fc6" order="0" type="ROOT" class="TRASH">
|
||||
<meta expanded="no" />
|
||||
<name status="sbaa94f" import="i613591">Trash</name>
|
||||
</item>
|
||||
</content>
|
||||
</novelWriterXML>
|
||||
|
||||
@@ -33,18 +33,6 @@
|
||||
<meta expanded="no" />
|
||||
<name status="s000000" import="i000004">Novel</name>
|
||||
</item>
|
||||
<item handle="0000000000009" parent="None" root="0000000000009" order="0" type="ROOT" class="PLOT">
|
||||
<meta expanded="no" />
|
||||
<name status="s000000" import="i000004">Plot</name>
|
||||
</item>
|
||||
<item handle="000000000000a" parent="None" root="000000000000a" order="0" type="ROOT" class="CHARACTER">
|
||||
<meta expanded="no" />
|
||||
<name status="s000000" import="i000004">Characters</name>
|
||||
</item>
|
||||
<item handle="000000000000b" parent="None" root="000000000000b" order="0" type="ROOT" class="WORLD">
|
||||
<meta expanded="no" />
|
||||
<name status="s000000" import="i000004">World</name>
|
||||
</item>
|
||||
<item handle="000000000000c" parent="0000000000008" root="0000000000008" order="0" type="FILE" class="NOVEL" layout="DOCUMENT">
|
||||
<meta expanded="no" heading="H1" charCount="20" wordCount="5" paraCount="1" cursorPos="0" />
|
||||
<name status="s000000" import="i000004" active="yes">Title Page</name>
|
||||
@@ -69,6 +57,14 @@
|
||||
<meta expanded="no" heading="H2" charCount="5" wordCount="1" paraCount="0" cursorPos="0" />
|
||||
<name status="s000000" import="i000004" active="yes">Hello</name>
|
||||
</item>
|
||||
<item handle="0000000000009" parent="None" root="0000000000009" order="0" type="ROOT" class="PLOT">
|
||||
<meta expanded="no" />
|
||||
<name status="s000000" import="i000004">Plot</name>
|
||||
</item>
|
||||
<item handle="000000000000a" parent="None" root="000000000000a" order="0" type="ROOT" class="CHARACTER">
|
||||
<meta expanded="no" />
|
||||
<name status="s000000" import="i000004">Characters</name>
|
||||
</item>
|
||||
<item handle="0000000000012" parent="000000000000a" root="000000000000a" order="0" type="FILE" class="CHARACTER" layout="NOTE">
|
||||
<meta expanded="no" heading="H1" charCount="11" wordCount="3" paraCount="1" cursorPos="0" />
|
||||
<name status="s000000" import="i000004" active="yes">Jane</name>
|
||||
@@ -77,5 +73,9 @@
|
||||
<meta expanded="no" heading="H1" charCount="11" wordCount="3" paraCount="1" cursorPos="0" />
|
||||
<name status="s000000" import="i000004" active="yes">John</name>
|
||||
</item>
|
||||
<item handle="000000000000b" parent="None" root="000000000000b" order="0" type="ROOT" class="WORLD">
|
||||
<meta expanded="no" />
|
||||
<name status="s000000" import="i000004">Locations</name>
|
||||
</item>
|
||||
</content>
|
||||
</novelWriterXML>
|
||||
|
||||
@@ -33,18 +33,6 @@
|
||||
<meta expanded="no" />
|
||||
<name status="s000000" import="i000004">Novel</name>
|
||||
</item>
|
||||
<item handle="0000000000009" parent="None" root="0000000000009" order="0" type="ROOT" class="PLOT">
|
||||
<meta expanded="no" />
|
||||
<name status="s000000" import="i000004">Plot</name>
|
||||
</item>
|
||||
<item handle="000000000000a" parent="None" root="000000000000a" order="0" type="ROOT" class="CHARACTER">
|
||||
<meta expanded="no" />
|
||||
<name status="s000000" import="i000004">Characters</name>
|
||||
</item>
|
||||
<item handle="000000000000b" parent="None" root="000000000000b" order="0" type="ROOT" class="WORLD">
|
||||
<meta expanded="no" />
|
||||
<name status="s000000" import="i000004">World</name>
|
||||
</item>
|
||||
<item handle="000000000000c" parent="0000000000008" root="0000000000008" order="0" type="FILE" class="NOVEL" layout="DOCUMENT">
|
||||
<meta expanded="no" heading="H1" charCount="20" wordCount="5" paraCount="1" cursorPos="0" />
|
||||
<name status="s000000" import="i000004" active="yes">Title Page</name>
|
||||
@@ -61,6 +49,18 @@
|
||||
<meta expanded="no" heading="H3" charCount="9" wordCount="2" paraCount="0" cursorPos="0" />
|
||||
<name status="s000000" import="i000004" active="yes">New Scene</name>
|
||||
</item>
|
||||
<item handle="0000000000009" parent="None" root="0000000000009" order="0" type="ROOT" class="PLOT">
|
||||
<meta expanded="no" />
|
||||
<name status="s000000" import="i000004">Plot</name>
|
||||
</item>
|
||||
<item handle="000000000000a" parent="None" root="000000000000a" order="0" type="ROOT" class="CHARACTER">
|
||||
<meta expanded="no" />
|
||||
<name status="s000000" import="i000004">Characters</name>
|
||||
</item>
|
||||
<item handle="000000000000b" parent="None" root="000000000000b" order="0" type="ROOT" class="WORLD">
|
||||
<meta expanded="no" />
|
||||
<name status="s000000" import="i000004">Locations</name>
|
||||
</item>
|
||||
<item handle="0000000000010" parent="None" root="0000000000010" order="0" type="ROOT" class="NOVEL">
|
||||
<meta expanded="no" />
|
||||
<name status="s000000" import="i000004">Novel</name>
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<?xml version='1.0' encoding='utf-8'?>
|
||||
<novelWriterXML appVersion="2.4rc1" hexVersion="0x020400c1" fileVersion="1.5" fileRevision="4" timeStamp="2024-04-09 22:34:16">
|
||||
<novelWriterXML appVersion="2.6b1" hexVersion="0x020600b1" fileVersion="1.5" fileRevision="4" timeStamp="2024-11-20 18:44:37">
|
||||
<project id="d0f3fe10-c6e6-4310-8bfd-181eb4224eed" saveCount="1" autoCount="1" editTime="0">
|
||||
<name>New Project</name>
|
||||
<author>Jane Doe</author>
|
||||
@@ -16,7 +16,7 @@
|
||||
</lastHandle>
|
||||
<autoReplace />
|
||||
<status>
|
||||
<entry key="s000000" count="15" red="100" green="100" blue="100" shape="SQUARE">New</entry>
|
||||
<entry key="s000000" count="16" red="100" green="100" blue="100" shape="SQUARE">New</entry>
|
||||
<entry key="s000001" count="0" red="200" green="50" blue="0" shape="SQUARE">Note</entry>
|
||||
<entry key="s000002" count="0" red="200" green="150" blue="0" shape="SQUARE">Draft</entry>
|
||||
<entry key="s000003" count="0" red="50" green="200" blue="0" shape="SQUARE">Finished</entry>
|
||||
@@ -28,23 +28,11 @@
|
||||
<entry key="i000007" count="0" red="50" green="200" blue="0" shape="SQUARE">Main</entry>
|
||||
</importance>
|
||||
</settings>
|
||||
<content items="18" novelWords="26" notesWords="0">
|
||||
<content items="19" novelWords="28" notesWords="0">
|
||||
<item handle="0000000000008" parent="None" root="0000000000008" order="0" type="ROOT" class="NOVEL">
|
||||
<meta expanded="no" />
|
||||
<name status="s000000" import="i000004">Novel</name>
|
||||
</item>
|
||||
<item handle="0000000000009" parent="None" root="0000000000009" order="0" type="ROOT" class="PLOT">
|
||||
<meta expanded="no" />
|
||||
<name status="s000000" import="i000004">Plot</name>
|
||||
</item>
|
||||
<item handle="000000000000a" parent="None" root="000000000000a" order="0" type="ROOT" class="CHARACTER">
|
||||
<meta expanded="no" />
|
||||
<name status="s000000" import="i000004">Characters</name>
|
||||
</item>
|
||||
<item handle="000000000000b" parent="None" root="000000000000b" order="0" type="ROOT" class="WORLD">
|
||||
<meta expanded="no" />
|
||||
<name status="s000000" import="i000004">World</name>
|
||||
</item>
|
||||
<item handle="000000000000c" parent="0000000000008" root="0000000000008" order="0" type="FILE" class="NOVEL" layout="DOCUMENT">
|
||||
<meta expanded="no" heading="H1" charCount="20" wordCount="5" paraCount="1" cursorPos="0" />
|
||||
<name status="s000000" import="i000004" active="yes">Title Page</name>
|
||||
@@ -57,6 +45,10 @@
|
||||
<meta expanded="no" heading="H2" charCount="11" wordCount="2" paraCount="0" cursorPos="0" />
|
||||
<name status="s000000" import="i000004" active="yes">New Chapter</name>
|
||||
</item>
|
||||
<item handle="0000000000019" parent="000000000000d" root="0000000000008" order="0" type="FILE" class="NOVEL" layout="DOCUMENT">
|
||||
<meta expanded="no" heading="H2" charCount="11" wordCount="2" paraCount="0" cursorPos="0" />
|
||||
<name status="s000000" import="i000004" active="yes">New Chapter</name>
|
||||
</item>
|
||||
<item handle="000000000000f" parent="000000000000d" root="0000000000008" order="0" type="FILE" class="NOVEL" layout="DOCUMENT">
|
||||
<meta expanded="no" heading="H3" charCount="9" wordCount="2" paraCount="0" cursorPos="0" />
|
||||
<name status="s000000" import="i000004" active="yes">New Scene</name>
|
||||
@@ -65,6 +57,10 @@
|
||||
<meta expanded="no" heading="H3" charCount="9" wordCount="2" paraCount="0" cursorPos="0" />
|
||||
<name status="s000000" import="i000004" active="yes">New Scene</name>
|
||||
</item>
|
||||
<item handle="000000000001a" parent="000000000000d" root="0000000000008" order="0" type="FILE" class="NOVEL" layout="DOCUMENT">
|
||||
<meta expanded="no" heading="H3" charCount="9" wordCount="2" paraCount="0" cursorPos="0" />
|
||||
<name status="s000000" import="i000004" active="yes">New Scene</name>
|
||||
</item>
|
||||
<item handle="0000000000011" parent="0000000000008" root="0000000000008" order="0" type="FOLDER" class="NOVEL">
|
||||
<meta expanded="no" />
|
||||
<name status="s000000" import="i000004">New Chapter</name>
|
||||
@@ -77,7 +73,7 @@
|
||||
<meta expanded="no" heading="H3" charCount="9" wordCount="2" paraCount="0" cursorPos="0" />
|
||||
<name status="s000000" import="i000004" active="yes">New Scene</name>
|
||||
</item>
|
||||
<item handle="0000000000014" parent="None" root="0000000000008" order="0" type="ROOT" class="NOVEL">
|
||||
<item handle="0000000000014" parent="None" root="0000000000014" order="0" type="ROOT" class="NOVEL">
|
||||
<meta expanded="no" />
|
||||
<name status="s000000" import="i000004">Novel</name>
|
||||
</item>
|
||||
@@ -97,9 +93,17 @@
|
||||
<meta expanded="no" heading="H3" charCount="9" wordCount="2" paraCount="0" cursorPos="0" />
|
||||
<name status="s000000" import="i000004" active="yes">New Scene</name>
|
||||
</item>
|
||||
<item handle="0000000000019" parent="000000000000d" root="0000000000008" order="0" type="FILE" class="NOVEL" layout="DOCUMENT">
|
||||
<meta expanded="no" heading="H2" charCount="11" wordCount="2" paraCount="0" cursorPos="0" />
|
||||
<name status="s000000" import="i000004" active="yes">New Chapter</name>
|
||||
<item handle="0000000000009" parent="None" root="0000000000009" order="0" type="ROOT" class="PLOT">
|
||||
<meta expanded="no" />
|
||||
<name status="s000000" import="i000004">Plot</name>
|
||||
</item>
|
||||
<item handle="000000000000a" parent="None" root="000000000000a" order="0" type="ROOT" class="CHARACTER">
|
||||
<meta expanded="no" />
|
||||
<name status="s000000" import="i000004">Characters</name>
|
||||
</item>
|
||||
<item handle="000000000000b" parent="None" root="000000000000b" order="0" type="ROOT" class="WORLD">
|
||||
<meta expanded="no" />
|
||||
<name status="s000000" import="i000004">Locations</name>
|
||||
</item>
|
||||
</content>
|
||||
</novelWriterXML>
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
<?xml version='1.0' encoding='utf-8'?>
|
||||
<cp:coreProperties xmlns:cp="http://schemas.openxmlformats.org/package/2006/metadata/core-properties" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:dcterms="http://purl.org/dc/terms/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
||||
<dcterms:created xsi:type="dcterms:W3CDTF">2024-10-28T20:12:57</dcterms:created>
|
||||
<dcterms:modified xsi:type="dcterms:W3CDTF">2024-10-28T20:12:57</dcterms:modified>
|
||||
<dcterms:created xsi:type="dcterms:W3CDTF">2024-11-20T19:45:15</dcterms:created>
|
||||
<dcterms:modified xsi:type="dcterms:W3CDTF">2024-11-20T19:45:15</dcterms:modified>
|
||||
<dc:creator>lipsum.com</dc:creator>
|
||||
<dc:title>Lorem Ipsum</dc:title>
|
||||
<dc:language>en_GB</dc:language>
|
||||
<cp:revision>50</cp:revision>
|
||||
<cp:revision>51</cp:revision>
|
||||
<cp:lastModifiedBy>lipsum.com</cp:lastModifiedBy>
|
||||
</cp:coreProperties>
|
||||
|
||||
@@ -93,7 +93,7 @@ def testCoreDocBuild_OpenDocument(monkeypatch, mockGUI, prjLipsum, fncPath, tstP
|
||||
|
||||
assert docBuild._outline is True
|
||||
|
||||
assert len(docBuild) == 21
|
||||
assert len(docBuild) == 22
|
||||
|
||||
# Check FODT Build
|
||||
# ================
|
||||
@@ -151,7 +151,7 @@ def testCoreDocBuild_OpenDocument(monkeypatch, mockGUI, prjLipsum, fncPath, tstP
|
||||
|
||||
with monkeypatch.context() as mp:
|
||||
mp.setattr("novelwriter.formats.toodt.ToOdt.doConvert", causeException)
|
||||
assert len(docBuild) == 21
|
||||
assert len(docBuild) == 22
|
||||
|
||||
count = 0
|
||||
error = []
|
||||
@@ -196,7 +196,7 @@ def testCoreDocBuild_HTML(monkeypatch, mockGUI, prjLipsum, fncPath, tstPaths):
|
||||
docBuild = NWBuildDocument(project, build)
|
||||
docBuild.queueAll()
|
||||
|
||||
assert len(docBuild) == 21
|
||||
assert len(docBuild) == 22
|
||||
|
||||
# Check HTML5 Build
|
||||
# =================
|
||||
@@ -264,7 +264,7 @@ def testCoreDocBuild_Markdown(monkeypatch, mockGUI, prjLipsum, fncPath, tstPaths
|
||||
docBuild = NWBuildDocument(project, build)
|
||||
docBuild.queueAll()
|
||||
|
||||
assert len(docBuild) == 21
|
||||
assert len(docBuild) == 22
|
||||
|
||||
# Check Standard Markdown Build
|
||||
# =============================
|
||||
@@ -332,7 +332,7 @@ def testCoreDocBuild_DocX(mockGUI, prjLipsum, fncPath):
|
||||
docBuild = NWBuildDocument(project, build)
|
||||
docBuild.queueAll()
|
||||
|
||||
assert len(docBuild) == 21
|
||||
assert len(docBuild) == 22
|
||||
|
||||
# Check Build
|
||||
# ===========
|
||||
@@ -365,7 +365,7 @@ def testCoreDocBuild_PDF(mockGUI, prjLipsum, fncPath):
|
||||
docBuild = NWBuildDocument(project, build)
|
||||
docBuild.queueAll()
|
||||
|
||||
assert len(docBuild) == 21
|
||||
assert len(docBuild) == 22
|
||||
|
||||
# Check Build
|
||||
# ===========
|
||||
@@ -397,7 +397,7 @@ def testCoreDocBuild_NWD(mockGUI, prjLipsum, fncPath, tstPaths):
|
||||
docBuild = NWBuildDocument(project, build)
|
||||
docBuild.queueAll()
|
||||
|
||||
assert len(docBuild) == 21
|
||||
assert len(docBuild) == 22
|
||||
|
||||
# Check NWD Build
|
||||
# ===============
|
||||
@@ -474,8 +474,8 @@ def testCoreDocBuild_Custom(mockGUI, fncPath: Path):
|
||||
|
||||
# Add an invalid item to the project
|
||||
nHandle = "0123456789def"
|
||||
project.tree._order.append(nHandle)
|
||||
project.tree._tree[nHandle] = None # type: ignore
|
||||
project.tree._items[nHandle] = None # type: ignore
|
||||
project.tree._nodes[nHandle] = None # type: ignore
|
||||
|
||||
docBuild.queueAll()
|
||||
assert len(docBuild) == 8
|
||||
@@ -517,12 +517,6 @@ def testCoreDocBuild_IterBuild(mockGUI, fncPath: Path, mockRnd):
|
||||
project.storage.getDocument(hPlotDoc).writeDocument("# Main Plot\n**Text**")
|
||||
project.storage.getDocument(hCharDoc).writeDocument("# Jane Doe\n~~Text~~")
|
||||
|
||||
# Fix project order as this has never been opened in a GUI
|
||||
project.tree.setOrder([ # type: ignore
|
||||
C.hNovelRoot, C.hTitlePage, C.hChapterDir, C.hChapterDoc, C.hSceneDoc,
|
||||
C.hPlotRoot, hPlotDoc, C.hCharRoot, hCharDoc, C.hWorldRoot
|
||||
])
|
||||
|
||||
docBuild = NWBuildDocument(project, build)
|
||||
docBuild.queueAll()
|
||||
assert len(docBuild) == 10
|
||||
|
||||
@@ -59,6 +59,7 @@ def testCoreIndex_LoadSave(qtbot, monkeypatch, prjLipsum, mockGUI, tstPaths):
|
||||
"67a8707f2f249": False, # Character ROOT
|
||||
"6c6afb1247750": False, # Plot ROOT
|
||||
"60bdf227455cc": False, # World ROOT
|
||||
"1ace7ab1a0fc6": False, # Trash ROOT
|
||||
}
|
||||
for tItem in project.tree:
|
||||
index.reIndexHandle(tItem.itemHandle)
|
||||
@@ -346,6 +347,7 @@ def testCoreIndex_ScanText(monkeypatch, mockGUI, fncPath, mockRnd):
|
||||
# Some items for fail to scan tests
|
||||
dHandle = project.newFolder("Folder", C.hNovelRoot)
|
||||
xHandle = project.newFile("No Layout", C.hNovelRoot)
|
||||
xIndex = project.tree.model.indexFromHandle(xHandle)
|
||||
assert isinstance(dHandle, str)
|
||||
assert isinstance(xHandle, str)
|
||||
|
||||
@@ -363,10 +365,13 @@ def testCoreIndex_ScanText(monkeypatch, mockGUI, fncPath, mockRnd):
|
||||
assert index.scanText(xHandle, "Hello World!") is False
|
||||
|
||||
# Create the trash folder
|
||||
tHandle = project.trashFolder()
|
||||
tNode = project.tree.trash
|
||||
assert tNode is not None
|
||||
tIndex = project.tree.model.indexFromNode(tNode)
|
||||
tHandle = tNode.item.itemHandle
|
||||
assert project.tree[tHandle] is not None
|
||||
xItem.setParent(tHandle)
|
||||
project.tree.updateItemData(xItem.itemHandle)
|
||||
|
||||
project.tree.model.multiMove([xIndex], tIndex)
|
||||
assert xItem.itemRoot == tHandle
|
||||
assert xItem.itemClass == nwItemClass.TRASH
|
||||
assert index.scanText(xHandle, "## Hello World!") is True
|
||||
@@ -374,9 +379,10 @@ def testCoreIndex_ScanText(monkeypatch, mockGUI, fncPath, mockRnd):
|
||||
|
||||
# Create the archive root
|
||||
aHandle = project.newRoot(nwItemClass.ARCHIVE)
|
||||
aIndex = project.tree.model.indexFromHandle(aHandle)
|
||||
assert project.tree[aHandle] is not None
|
||||
xItem.setParent(aHandle)
|
||||
project.tree.updateItemData(xItem.itemHandle)
|
||||
|
||||
project.tree.model.multiMove([xIndex], aIndex)
|
||||
assert index.scanText(xHandle, "### Hello World!") is True
|
||||
assert xItem.mainHeading == "H3"
|
||||
|
||||
@@ -901,7 +907,8 @@ def testCoreIndex_ExtractData(mockGUI, fncPath, mockRnd):
|
||||
]
|
||||
|
||||
# Add a fake handle to the tree and check that it's ignored
|
||||
project.tree._order.append("0000000000000")
|
||||
project.tree._items["0000000000000"] = None # type: ignore
|
||||
project.tree._nodes["0000000000000"] = None # type: ignore
|
||||
assert [(h, t) for h, t, _ in index._itemIndex.iterNovelStructure(activeOnly=False)] == [
|
||||
(C.hTitlePage, "T0001"),
|
||||
(C.hChapterDoc, "T0001"),
|
||||
@@ -912,7 +919,8 @@ def testCoreIndex_ExtractData(mockGUI, fncPath, mockRnd):
|
||||
(sHandle, "T0001"),
|
||||
(tHandle, "T0001"),
|
||||
]
|
||||
project.tree._order.remove("0000000000000")
|
||||
del project.tree._items["0000000000000"]
|
||||
del project.tree._nodes["0000000000000"]
|
||||
|
||||
# Extract stats
|
||||
assert index.getNovelWordCount(activeOnly=False) == 43
|
||||
@@ -1281,7 +1289,8 @@ def testCoreIndex_ItemIndex(mockGUI, fncPath, mockRnd):
|
||||
assert nStruct[0][0] == uHandle
|
||||
|
||||
# Inject garbage into tree
|
||||
project.tree._order.append("stuff")
|
||||
project.tree._items["stuff"] = None # type: ignore
|
||||
project.tree._nodes["stuff"] = None # type: ignore
|
||||
nStruct = list(itemIndex.iterNovelStructure())
|
||||
assert len(nStruct) == 4
|
||||
assert nStruct[0][0] == nHandle
|
||||
|
||||
@@ -29,12 +29,8 @@ from PyQt5.QtWidgets import QMessageBox
|
||||
|
||||
from novelwriter import CONFIG, SHARED
|
||||
from novelwriter.constants import nwFiles
|
||||
from novelwriter.core.index import NWIndex
|
||||
from novelwriter.core.item import NWItem
|
||||
from novelwriter.core.options import OptionState
|
||||
from novelwriter.core.project import NWProject, NWProjectState
|
||||
from novelwriter.core.projectxml import ProjectXMLReader, ProjectXMLWriter, XMLReadState
|
||||
from novelwriter.core.tree import NWTree
|
||||
from novelwriter.enum import nwItemClass
|
||||
|
||||
from tests.mocked import causeOSError
|
||||
@@ -284,7 +280,7 @@ def testCoreProject_Open(monkeypatch, caplog, mockGUI, fncPath, mockRnd):
|
||||
|
||||
# Fail checking items should still pass
|
||||
with monkeypatch.context() as mp:
|
||||
mp.setattr("novelwriter.core.tree.NWTree.updateItemData", lambda *a: False)
|
||||
mp.setattr("novelwriter.core.tree.NWTree.checkConsistency", lambda *a: (1, 0))
|
||||
assert project.openProject(fncPath, clearLock=True) is True
|
||||
|
||||
# Trigger an index rebuild
|
||||
@@ -326,70 +322,6 @@ def testCoreProject_Save(monkeypatch, mockGUI, mockRnd, fncPath):
|
||||
project.closeProject()
|
||||
|
||||
|
||||
@pytest.mark.core
|
||||
def testCoreProject_AccessItems(mockGUI, fncPath, mockRnd):
|
||||
"""Test helper functions for the project folder."""
|
||||
project = NWProject()
|
||||
buildTestProject(project, fncPath)
|
||||
|
||||
# Storage Objects
|
||||
assert isinstance(project.index, NWIndex)
|
||||
assert isinstance(project.tree, NWTree)
|
||||
assert isinstance(project.options, OptionState)
|
||||
|
||||
# Move Novel ROOT to after its files
|
||||
oldOrder = [
|
||||
C.hNovelRoot,
|
||||
C.hPlotRoot,
|
||||
C.hCharRoot,
|
||||
C.hWorldRoot,
|
||||
C.hTitlePage,
|
||||
C.hChapterDir,
|
||||
C.hChapterDoc,
|
||||
C.hSceneDoc,
|
||||
]
|
||||
newOrder = [
|
||||
C.hTitlePage,
|
||||
C.hChapterDoc,
|
||||
C.hSceneDoc,
|
||||
C.hChapterDir,
|
||||
C.hNovelRoot,
|
||||
C.hPlotRoot,
|
||||
C.hCharRoot,
|
||||
C.hWorldRoot,
|
||||
]
|
||||
assert project.tree.handles() == oldOrder
|
||||
project.setTreeOrder(newOrder)
|
||||
assert project.tree.handles() == newOrder
|
||||
|
||||
# Add a non-existing item
|
||||
project.tree._order.append(C.hInvalid)
|
||||
|
||||
# Add an item with a non-existent parent
|
||||
nHandle = project.newFile("Test File", C.hChapterDir)
|
||||
nItem = project.tree[nHandle]
|
||||
assert isinstance(nItem, NWItem)
|
||||
nItem.setParent("cba9876543210")
|
||||
assert nItem.itemParent == "cba9876543210"
|
||||
|
||||
retOrder = []
|
||||
for tItem in project.iterProjectItems():
|
||||
retOrder.append(tItem.itemHandle)
|
||||
|
||||
assert retOrder == [
|
||||
C.hNovelRoot,
|
||||
C.hPlotRoot,
|
||||
C.hCharRoot,
|
||||
C.hWorldRoot,
|
||||
nHandle,
|
||||
C.hTitlePage,
|
||||
C.hChapterDir,
|
||||
C.hChapterDoc,
|
||||
C.hSceneDoc,
|
||||
]
|
||||
assert nItem.itemParent is None
|
||||
|
||||
|
||||
@pytest.mark.core
|
||||
def testCoreProject_Methods(monkeypatch, mockGUI, fncPath, mockRnd):
|
||||
"""Test other project class methods and functions."""
|
||||
@@ -411,13 +343,6 @@ def testCoreProject_Methods(monkeypatch, mockGUI, fncPath, mockRnd):
|
||||
mp.setattr("novelwriter.core.project.time", lambda: 1600005600)
|
||||
assert project.currentEditTime == 6834
|
||||
|
||||
# Trash folder
|
||||
# Should create on first call, and just returned on later calls
|
||||
hTrash = "0000000000010"
|
||||
assert project.tree[hTrash] is None
|
||||
assert project.trashFolder() == hTrash
|
||||
assert project.trashFolder() == hTrash
|
||||
|
||||
# Spell check
|
||||
project.setProjectChanged(False)
|
||||
project.data.setSpellCheck(True)
|
||||
@@ -480,23 +405,6 @@ def testCoreProject_Methods(monkeypatch, mockGUI, fncPath, mockRnd):
|
||||
assert project.data.autoReplace == {"A": "B", "C": "D"}
|
||||
assert project.projChanged
|
||||
|
||||
# Change project tree order
|
||||
oldOrder = [
|
||||
"0000000000008", "0000000000009", "000000000000a",
|
||||
"000000000000b", "000000000000c", "000000000000d",
|
||||
"000000000000e", "000000000000f", "0000000000010",
|
||||
]
|
||||
newOrder = [
|
||||
"000000000000b", "000000000000c", "000000000000d",
|
||||
"0000000000008", "0000000000009", "000000000000a",
|
||||
"000000000000e", "000000000000f",
|
||||
]
|
||||
assert project.tree.handles() == oldOrder
|
||||
project.setTreeOrder(newOrder)
|
||||
assert project.tree.handles() == newOrder
|
||||
project.setTreeOrder(oldOrder)
|
||||
assert project.tree.handles() == oldOrder
|
||||
|
||||
|
||||
@pytest.mark.core
|
||||
def testCoreProject_Backup(monkeypatch, mockGUI, fncPath, tstPaths):
|
||||
|
||||
@@ -38,8 +38,6 @@ def testDlgSplit_Main(qtbot, monkeypatch, nwGUI, projPath, mockRnd):
|
||||
buildTestProject(nwGUI, projPath)
|
||||
|
||||
project = SHARED.project
|
||||
projTree = nwGUI.projView.projTree
|
||||
|
||||
docText = (
|
||||
"Text\n\n"
|
||||
"##! Prologue\n\nText\n\n"
|
||||
@@ -58,7 +56,6 @@ def testDlgSplit_Main(qtbot, monkeypatch, nwGUI, projPath, mockRnd):
|
||||
hSplitDoc = project.newFile("Split Doc", C.hNovelRoot)
|
||||
assert hSplitDoc is not None
|
||||
project.writeNewFile(hSplitDoc, 1, True, docText)
|
||||
projTree.revealNewTreeItem(hSplitDoc, nHandle=C.hNovelRoot, wordCount=True)
|
||||
|
||||
docText = f"# Split Doc\n\n{docText}"
|
||||
|
||||
|
||||
@@ -661,7 +661,7 @@ def testFmtToDocX_SaveDocument(mockGUI, prjLipsum, fncPath, tstPaths):
|
||||
(0, True), (1, True), (2, True), (3, True), (4, True), (5, False),
|
||||
(6, True), (7, True), (8, True), (9, False), (10, False), (11, True),
|
||||
(12, True), (13, True), (14, True), (15, True), (16, True), (17, True),
|
||||
(18, True), (19, True), (20, True),
|
||||
(18, True), (19, True), (20, True), (21, False),
|
||||
]
|
||||
|
||||
assert docPath.exists()
|
||||
|
||||
@@ -1615,7 +1615,6 @@ def testGuiEditor_Tags(qtbot, nwGUI, projPath, ipsumText, mockRnd):
|
||||
assert nwGUI.openDocument(cHandle) is True
|
||||
docEditor.replaceText(text)
|
||||
nwGUI.saveDocument()
|
||||
assert nwGUI.projView.projTree.revealNewTreeItem(cHandle)
|
||||
|
||||
# Follow Tag
|
||||
# ==========
|
||||
@@ -1715,7 +1714,6 @@ def testGuiEditor_Completer(qtbot, nwGUI, projPath, mockRnd):
|
||||
assert nwGUI.openDocument(cHandle) is True
|
||||
docEditor.replaceText(text)
|
||||
nwGUI.saveDocument()
|
||||
assert nwGUI.projView.projTree.revealNewTreeItem(cHandle)
|
||||
|
||||
docEditor.replaceText("")
|
||||
completer = docEditor._completer
|
||||
|
||||
@@ -52,8 +52,8 @@ def testGuiViewer_Main(qtbot, monkeypatch, nwGUI, prjLipsum):
|
||||
assert docViewer.loadText("b3643d0f92e32") is False
|
||||
|
||||
# Middle-click the selected item
|
||||
item = nwGUI.projView.projTree._getTreeItem("88243afbe5ed8")
|
||||
rect = nwGUI.projView.projTree.visualItemRect(item)
|
||||
index = SHARED.project.tree.model.indexFromHandle("88243afbe5ed8")
|
||||
rect = nwGUI.projView.projTree.visualRect(index)
|
||||
qtbot.mouseClick(nwGUI.projView.projTree.viewport(), Qt.MidButton, pos=rect.center())
|
||||
assert docViewer.docHandle == "88243afbe5ed8"
|
||||
|
||||
|
||||
@@ -39,7 +39,7 @@ def testGuiViewerPanel_BackRefs(qtbot, monkeypatch, nwGUI, projPath, mockRnd):
|
||||
|
||||
buildTestProject(nwGUI, projPath)
|
||||
projTree = nwGUI.projView.projTree
|
||||
projTree._getTreeItem(C.hChapterDir).setExpanded(True)
|
||||
projTree.expandAll()
|
||||
viewPanel = nwGUI.docViewerPanel
|
||||
tabBackRefs = viewPanel.tabBackRefs
|
||||
|
||||
@@ -128,7 +128,7 @@ def testGuiViewerPanel_Tags(qtbot, monkeypatch, caplog, nwGUI, projPath, mockRnd
|
||||
|
||||
buildTestProject(nwGUI, projPath)
|
||||
projTree = nwGUI.projView.projTree
|
||||
projTree._getTreeItem(C.hChapterDir).setExpanded(True)
|
||||
projTree.expandAll()
|
||||
viewPanel = nwGUI.docViewerPanel
|
||||
|
||||
nwGUI.openDocument(C.hSceneDoc)
|
||||
|
||||
@@ -144,7 +144,7 @@ def testGuiMain_ProjectTreeItems(qtbot, monkeypatch, nwGUI, projPath, mockRnd):
|
||||
with monkeypatch.context() as mp:
|
||||
mp.setattr(GuiProjectTree, "hasFocus", lambda *a: True)
|
||||
assert nwGUI.docEditor.docHandle is None
|
||||
nwGUI.projView.projTree._getTreeItem(sHandle).setSelected(True)
|
||||
nwGUI.projView.projTree.setSelectedHandle(sHandle)
|
||||
nwGUI._keyPressReturn()
|
||||
assert nwGUI.docEditor.docHandle == sHandle
|
||||
nwGUI.closeDocument()
|
||||
@@ -711,7 +711,6 @@ def testGuiMain_Features(qtbot, monkeypatch, nwGUI, projPath, mockRnd):
|
||||
cHandle = SHARED.project.newFile("Jane", C.hCharRoot)
|
||||
newDoc = SHARED.project.storage.getDocument(cHandle)
|
||||
newDoc.writeDocument("# Jane\n\n@tag: Jane\n\n")
|
||||
nwGUI.projView.projTree.revealNewTreeItem(cHandle)
|
||||
nwGUI.rebuildIndex(beQuiet=True)
|
||||
|
||||
assert SHARED.focusMode is False
|
||||
|
||||
@@ -374,7 +374,6 @@ def testGuiMainMenu_Insert(qtbot, monkeypatch, nwGUI, fncPath, projPath, mockRnd
|
||||
"""Test the Insert menu."""
|
||||
buildTestProject(nwGUI, projPath)
|
||||
|
||||
assert nwGUI.projView.projTree._getTreeItem(C.hSceneDoc) is not None
|
||||
assert nwGUI.openDocument(C.hSceneDoc) is True
|
||||
mainMenu = nwGUI.mainMenu
|
||||
docEditor = nwGUI.docEditor
|
||||
|
||||
@@ -46,7 +46,7 @@ def testGuiNovelTree_TreeItems(qtbot, monkeypatch, nwGUI, projPath, mockRnd):
|
||||
|
||||
nwGUI._switchFocus(nwFocus.TREE)
|
||||
nwGUI.projView.projTree.clearSelection()
|
||||
nwGUI.projView.projTree._getTreeItem(C.hCharRoot).setSelected(True)
|
||||
nwGUI.projView.projTree.setSelectedHandle(C.hCharRoot)
|
||||
nwGUI.projView.projTree.newTreeItem(nwItemType.FILE)
|
||||
|
||||
contentPath = SHARED.project.storage.contentPath
|
||||
|
||||
@@ -198,7 +198,6 @@ def testGuiOutline_Content(qtbot, monkeypatch, nwGUI, prjLipsum, fncPath, tstPat
|
||||
|
||||
# Add a second novel folder
|
||||
newHandle = SHARED.project.newRoot(nwItemClass.NOVEL)
|
||||
nwGUI.projView.projTree.revealNewTreeItem(newHandle)
|
||||
|
||||
# Check new values in dropdown list
|
||||
assert outlineBar.novelValue.itemData(0) == lipHandle
|
||||
@@ -217,7 +216,6 @@ def testGuiOutline_Content(qtbot, monkeypatch, nwGUI, prjLipsum, fncPath, tstPat
|
||||
aHandle = SHARED.project.newFile(dTitle, newHandle)
|
||||
hHash = "#"*hLevel
|
||||
writeFile(prjLipsum / "content" / f"{aHandle}.nwd", f"{hHash} {dTitle}\n\n")
|
||||
nwGUI.projView.projTree.revealNewTreeItem(aHandle)
|
||||
|
||||
nwGUI.rebuildIndex()
|
||||
|
||||
|
||||
@@ -742,29 +742,28 @@ def testGuiProjTree_Duplicate(qtbot, monkeypatch, nwGUI: GuiMain, projPath, mock
|
||||
assert len(SHARED.project.tree) == 8
|
||||
|
||||
projTree = nwGUI.projView.projTree
|
||||
projTree._getTreeItem(C.hNovelRoot).setExpanded(True) # type: ignore
|
||||
projTree._getTreeItem(C.hChapterDir).setExpanded(True) # type: ignore
|
||||
projTree.expandAll()
|
||||
|
||||
# Nothing to do
|
||||
assert projTree._duplicateFromHandle(C.hInvalid) is False
|
||||
assert projTree.duplicateFromHandle(C.hInvalid) is False
|
||||
assert len(SHARED.project.tree) == 8
|
||||
|
||||
# Duplicate title page, but select no
|
||||
with monkeypatch.context() as mp:
|
||||
mp.setattr(QMessageBox, "result", lambda *a: QMessageBox.StandardButton.No)
|
||||
assert projTree._duplicateFromHandle(C.hTitlePage) is False
|
||||
assert projTree.duplicateFromHandle(C.hTitlePage) is False
|
||||
assert len(SHARED.project.tree) == 8
|
||||
|
||||
# Duplicate title page
|
||||
assert projTree._duplicateFromHandle(C.hTitlePage) is True
|
||||
assert projTree.duplicateFromHandle(C.hTitlePage) is True
|
||||
assert len(SHARED.project.tree) == 9
|
||||
|
||||
# Duplicate folder
|
||||
assert projTree._duplicateFromHandle(C.hChapterDir) is True
|
||||
assert projTree.duplicateFromHandle(C.hChapterDir) is True
|
||||
assert len(SHARED.project.tree) == 12
|
||||
|
||||
# Duplicate novel root
|
||||
assert projTree._duplicateFromHandle(C.hNovelRoot) is True
|
||||
assert projTree.duplicateFromHandle(C.hNovelRoot) is True
|
||||
assert len(SHARED.project.tree) == 21
|
||||
|
||||
# Check tree order that all items are next to each other
|
||||
@@ -783,7 +782,7 @@ def testGuiProjTree_Duplicate(qtbot, monkeypatch, nwGUI: GuiMain, projPath, mock
|
||||
|
||||
# Should only create the folder, and skip the two files because the
|
||||
# next handle is already a file
|
||||
assert projTree._duplicateFromHandle(C.hChapterDir) is True
|
||||
assert projTree.duplicateFromHandle(C.hChapterDir) is True
|
||||
assert len(SHARED.project.tree) == 22
|
||||
|
||||
# qtbot.stop()
|
||||
@@ -801,7 +800,7 @@ def testGuiProjTree_AutoScroll(qtbot, monkeypatch, nwGUI: GuiMain, projPath, moc
|
||||
monkeypatch.setattr(QTimer, "start", lambda *a: None)
|
||||
|
||||
projTree.setSelectedHandle(C.hChapterDir, True)
|
||||
projTree._getTreeItem(C.hChapterDir).setExpanded(True) # type: ignore
|
||||
projTree.expandAll()
|
||||
for i in range(100):
|
||||
projTree.newTreeItem(nwItemType.FILE, None, 3, False)
|
||||
|
||||
|
||||
@@ -37,7 +37,6 @@ def testGuiStatusBar_Main(qtbot, nwGUI, projPath, mockRnd):
|
||||
cHandle = SHARED.project.newFile("A Note", C.hCharRoot)
|
||||
newDoc = SHARED.project.storage.getDocument(cHandle)
|
||||
newDoc.writeDocument("# A Note\n\n")
|
||||
nwGUI.projView.projTree.revealNewTreeItem(cHandle)
|
||||
nwGUI.rebuildIndex(beQuiet=True)
|
||||
|
||||
# Reference Time
|
||||
|
||||
@@ -167,6 +167,7 @@ def testToolBuildSettings_Filter(qtbot, nwGUI, projPath, mockRnd):
|
||||
C.hCharRoot: (False, FilterMode.SKIPPED),
|
||||
hCharDoc: (False, FilterMode.FILTERED),
|
||||
C.hWorldRoot: (False, FilterMode.SKIPPED),
|
||||
C.hTrashRoot: (False, FilterMode.SKIPPED),
|
||||
}
|
||||
|
||||
# Switch on note docs
|
||||
@@ -182,6 +183,7 @@ def testToolBuildSettings_Filter(qtbot, nwGUI, projPath, mockRnd):
|
||||
C.hCharRoot: (False, FilterMode.SKIPPED),
|
||||
hCharDoc: (True, FilterMode.FILTERED), # Now enabled
|
||||
C.hWorldRoot: (False, FilterMode.SKIPPED),
|
||||
C.hTrashRoot: (False, FilterMode.SKIPPED),
|
||||
}
|
||||
|
||||
# Switch on inactive docs
|
||||
@@ -197,6 +199,7 @@ def testToolBuildSettings_Filter(qtbot, nwGUI, projPath, mockRnd):
|
||||
C.hCharRoot: (False, FilterMode.SKIPPED),
|
||||
hCharDoc: (True, FilterMode.FILTERED),
|
||||
C.hWorldRoot: (False, FilterMode.SKIPPED),
|
||||
C.hTrashRoot: (False, FilterMode.SKIPPED),
|
||||
}
|
||||
|
||||
# Set chapter and scene docs to included
|
||||
@@ -214,6 +217,7 @@ def testToolBuildSettings_Filter(qtbot, nwGUI, projPath, mockRnd):
|
||||
C.hCharRoot: (False, FilterMode.SKIPPED),
|
||||
hCharDoc: (True, FilterMode.FILTERED),
|
||||
C.hWorldRoot: (False, FilterMode.SKIPPED),
|
||||
C.hTrashRoot: (False, FilterMode.SKIPPED),
|
||||
}
|
||||
|
||||
# Set char and plot docs to excluded
|
||||
@@ -232,6 +236,7 @@ def testToolBuildSettings_Filter(qtbot, nwGUI, projPath, mockRnd):
|
||||
C.hCharRoot: (False, FilterMode.SKIPPED),
|
||||
hCharDoc: (False, FilterMode.EXCLUDED), # Now excluded
|
||||
C.hWorldRoot: (False, FilterMode.SKIPPED),
|
||||
C.hTrashRoot: (False, FilterMode.SKIPPED),
|
||||
}
|
||||
|
||||
# Switch on novel docs
|
||||
@@ -247,6 +252,7 @@ def testToolBuildSettings_Filter(qtbot, nwGUI, projPath, mockRnd):
|
||||
C.hCharRoot: (False, FilterMode.SKIPPED),
|
||||
hCharDoc: (False, FilterMode.EXCLUDED),
|
||||
C.hWorldRoot: (False, FilterMode.SKIPPED),
|
||||
C.hTrashRoot: (False, FilterMode.SKIPPED),
|
||||
}
|
||||
|
||||
# Selecting only novel root should iterate through all children
|
||||
@@ -264,6 +270,7 @@ def testToolBuildSettings_Filter(qtbot, nwGUI, projPath, mockRnd):
|
||||
C.hCharRoot: (False, FilterMode.SKIPPED),
|
||||
hCharDoc: (False, FilterMode.EXCLUDED),
|
||||
C.hWorldRoot: (False, FilterMode.SKIPPED),
|
||||
C.hTrashRoot: (False, FilterMode.SKIPPED),
|
||||
}
|
||||
|
||||
# Set everything back to filtered
|
||||
@@ -284,6 +291,7 @@ def testToolBuildSettings_Filter(qtbot, nwGUI, projPath, mockRnd):
|
||||
C.hCharRoot: (False, FilterMode.SKIPPED),
|
||||
hCharDoc: (True, FilterMode.FILTERED),
|
||||
C.hWorldRoot: (False, FilterMode.SKIPPED),
|
||||
C.hTrashRoot: (False, FilterMode.SKIPPED),
|
||||
}
|
||||
|
||||
# Check handling of invalid project items
|
||||
|
||||
@@ -52,6 +52,7 @@ class C:
|
||||
hInvalid = "0000000000000"
|
||||
hNovelRoot = "0000000000008"
|
||||
hPlotRoot = "0000000000009"
|
||||
hTrashRoot = "0000000000010"
|
||||
hCharRoot = "000000000000a"
|
||||
hWorldRoot = "000000000000b"
|
||||
hTitlePage = "000000000000c"
|
||||
|
||||
Reference in New Issue
Block a user