Also make tree and options properties of the project
This commit is contained in:
@@ -64,7 +64,7 @@ def testCoreDocument_LoadSave(monkeypatch, mockGUI, nwMinimal):
|
||||
assert theDoc.readDocument() == "### New Scene\n\n"
|
||||
|
||||
# Try to open a new (non-existent) file
|
||||
nHandle = theProject.projTree.findRoot(nwItemClass.NOVEL)
|
||||
nHandle = theProject.tree.findRoot(nwItemClass.NOVEL)
|
||||
assert nHandle is not None
|
||||
xHandle = theProject.newFile("New File", nHandle)
|
||||
theDoc = NWDoc(theProject, xHandle)
|
||||
|
||||
@@ -54,7 +54,7 @@ def testCoreIndex_LoadSave(monkeypatch, nwLipsum, mockGUI, outDir, refDir):
|
||||
"6c6afb1247750": False, # Plot ROOT
|
||||
"60bdf227455cc": False, # World ROOT
|
||||
}
|
||||
for tItem in theProject.projTree:
|
||||
for tItem in theProject.tree:
|
||||
assert theIndex.reIndexHandle(tItem.itemHandle) is notIndexable.get(tItem.itemHandle, True)
|
||||
|
||||
assert theIndex.reIndexHandle(None) is False
|
||||
@@ -180,8 +180,8 @@ def testCoreIndex_CheckThese(nwMinimal, mockGUI):
|
||||
theIndex = NWIndex(theProject)
|
||||
nHandle = theProject.newFile("Hello", "a508bb932959c")
|
||||
cHandle = theProject.newFile("Jane", "afb3043c7b2b3")
|
||||
nItem = theProject.projTree[nHandle]
|
||||
cItem = theProject.projTree[cHandle]
|
||||
nItem = theProject.tree[nHandle]
|
||||
cItem = theProject.tree[cHandle]
|
||||
|
||||
assert theIndex.novelChangedSince(0) is False
|
||||
assert theIndex.notesChangedSince(0) is False
|
||||
@@ -258,7 +258,7 @@ def testCoreIndex_ScanText(nwMinimal, mockGUI):
|
||||
# Some items for fail to scan tests
|
||||
dHandle = theProject.newFolder("Folder", "a508bb932959c")
|
||||
xHandle = theProject.newFile("No Layout", "a508bb932959c")
|
||||
xItem = theProject.projTree[xHandle]
|
||||
xItem = theProject.tree[xHandle]
|
||||
xItem.setLayout(nwItemLayout.NO_LAYOUT)
|
||||
|
||||
# Check invalid data
|
||||
@@ -272,18 +272,18 @@ def testCoreIndex_ScanText(nwMinimal, mockGUI):
|
||||
|
||||
# Create the trash folder
|
||||
tHandle = theProject.trashFolder()
|
||||
assert theProject.projTree[tHandle] is not None
|
||||
assert theProject.tree[tHandle] is not None
|
||||
xItem.setParent(tHandle)
|
||||
theProject.projTree.updateItemData(xItem.itemHandle)
|
||||
theProject.tree.updateItemData(xItem.itemHandle)
|
||||
assert xItem.itemRoot == tHandle
|
||||
assert xItem.itemClass == nwItemClass.TRASH
|
||||
assert theIndex.scanText(xHandle, "Hello World!") is False
|
||||
|
||||
# Create the archive root
|
||||
aHandle = theProject.newRoot(nwItemClass.ARCHIVE)
|
||||
assert theProject.projTree[aHandle] is not None
|
||||
assert theProject.tree[aHandle] is not None
|
||||
xItem.setParent(aHandle)
|
||||
theProject.projTree.updateItemData(xItem.itemHandle)
|
||||
theProject.tree.updateItemData(xItem.itemHandle)
|
||||
assert theIndex.scanText(xHandle, "Hello World!") is False
|
||||
|
||||
# Make some usable items
|
||||
@@ -433,7 +433,7 @@ def testCoreIndex_ScanText(nwMinimal, mockGUI):
|
||||
# Page wo/Title
|
||||
# =============
|
||||
|
||||
theProject.projTree[pHandle]._layout = nwItemLayout.DOCUMENT
|
||||
theProject.tree[pHandle]._layout = nwItemLayout.DOCUMENT
|
||||
assert theIndex.scanText(pHandle, (
|
||||
"This is a page with some text on it.\n\n"
|
||||
))
|
||||
@@ -446,7 +446,7 @@ def testCoreIndex_ScanText(nwMinimal, mockGUI):
|
||||
assert theIndex._fileIndex[pHandle]["T000000"]["pCount"] == 1
|
||||
assert theIndex._fileIndex[pHandle]["T000000"]["synopsis"] == ""
|
||||
|
||||
theProject.projTree[pHandle]._layout = nwItemLayout.NOTE
|
||||
theProject.tree[pHandle]._layout = nwItemLayout.NOTE
|
||||
assert theIndex.scanText(pHandle, (
|
||||
"This is a page with some text on it.\n\n"
|
||||
))
|
||||
@@ -499,7 +499,7 @@ def testCoreIndex_ExtractData(nwMinimal, mockGUI):
|
||||
assert theKeys == ["%s:T000001" % nHandle]
|
||||
|
||||
# Check that excluded files can be skipped
|
||||
theProject.projTree[nHandle].setExported(False)
|
||||
theProject.tree[nHandle].setExported(False)
|
||||
|
||||
theKeys = []
|
||||
for aKey, _, _, _ in theIndex.novelStructure(skipExcluded=False):
|
||||
@@ -631,9 +631,9 @@ def testCoreIndex_ExtractData(nwMinimal, mockGUI):
|
||||
sHandle = theProject.newFile("Scene One", "a508bb932959c")
|
||||
tHandle = theProject.newFile("Scene Two", "a508bb932959c")
|
||||
|
||||
theProject.projTree[hHandle].itemLayout == nwItemLayout.DOCUMENT
|
||||
theProject.projTree[sHandle].itemLayout == nwItemLayout.DOCUMENT
|
||||
theProject.projTree[tHandle].itemLayout == nwItemLayout.DOCUMENT
|
||||
theProject.tree[hHandle].itemLayout == nwItemLayout.DOCUMENT
|
||||
theProject.tree[sHandle].itemLayout == nwItemLayout.DOCUMENT
|
||||
theProject.tree[tHandle].itemLayout == nwItemLayout.DOCUMENT
|
||||
|
||||
assert theIndex.scanText(hHandle, "## Chapter One\n\n")
|
||||
assert theIndex.scanText(sHandle, "### Scene One\n\n")
|
||||
@@ -643,9 +643,9 @@ def testCoreIndex_ExtractData(nwMinimal, mockGUI):
|
||||
assert theIndex._listNovelHandles(True) == [hHandle, sHandle, tHandle]
|
||||
|
||||
# Add a fake handle to the tree and check that it's ignored
|
||||
theProject.projTree._treeOrder.append("0000000000000")
|
||||
theProject.tree._treeOrder.append("0000000000000")
|
||||
assert theIndex._listNovelHandles(False) == [nHandle, hHandle, sHandle, tHandle]
|
||||
theProject.projTree._treeOrder.remove("0000000000000")
|
||||
theProject.tree._treeOrder.remove("0000000000000")
|
||||
|
||||
# Extract stats
|
||||
assert theIndex.getNovelWordCount(False) == 34
|
||||
|
||||
@@ -634,17 +634,17 @@ def testCoreProject_AccessItems(nwMinimal, mockGUI):
|
||||
"afb3043c7b2b3", # ROOT: Characters
|
||||
"9d5247ab588e0", # ROOT: World
|
||||
]
|
||||
assert theProject.projTree.handles() == oldOrder
|
||||
assert theProject.tree.handles() == oldOrder
|
||||
assert theProject.setTreeOrder(newOrder)
|
||||
assert theProject.projTree.handles() == newOrder
|
||||
assert theProject.tree.handles() == newOrder
|
||||
|
||||
# Add a non-existing item
|
||||
theProject.projTree._treeOrder.append("01234567789abc")
|
||||
theProject.tree._treeOrder.append("01234567789abc")
|
||||
|
||||
# Add an item with a non-existent parent
|
||||
nHandle = theProject.newFile("Test File", "a6d311a93600a")
|
||||
theProject.projTree[nHandle].setParent("cba9876543210")
|
||||
assert theProject.projTree[nHandle].itemParent == "cba9876543210"
|
||||
theProject.tree[nHandle].setParent("cba9876543210")
|
||||
assert theProject.tree[nHandle].itemParent == "cba9876543210"
|
||||
|
||||
retOrder = []
|
||||
for tItem in theProject.getProjectItems():
|
||||
@@ -661,7 +661,7 @@ def testCoreProject_AccessItems(nwMinimal, mockGUI):
|
||||
"f5ab3e30151e1", # FILE: New Chapter
|
||||
"8c659a11cd429", # FILE: New Scene
|
||||
]
|
||||
assert theProject.projTree[nHandle].itemParent is None
|
||||
assert theProject.tree[nHandle].itemParent is None
|
||||
|
||||
# END Test testCoreProject_AccessItems
|
||||
|
||||
@@ -679,15 +679,15 @@ def testCoreProject_StatusImport(mockGUI, fncDir, mockRnd):
|
||||
# Change Status
|
||||
# =============
|
||||
|
||||
theProject.projTree["0000000000014"].setStatus("Finished")
|
||||
theProject.projTree["0000000000015"].setStatus("Draft")
|
||||
theProject.projTree["0000000000016"].setStatus("Note")
|
||||
theProject.projTree["0000000000017"].setStatus("Finished")
|
||||
theProject.tree["0000000000014"].setStatus("Finished")
|
||||
theProject.tree["0000000000015"].setStatus("Draft")
|
||||
theProject.tree["0000000000016"].setStatus("Note")
|
||||
theProject.tree["0000000000017"].setStatus("Finished")
|
||||
|
||||
assert theProject.projTree["0000000000014"].itemStatus == statusKeys[3]
|
||||
assert theProject.projTree["0000000000015"].itemStatus == statusKeys[2]
|
||||
assert theProject.projTree["0000000000016"].itemStatus == statusKeys[1]
|
||||
assert theProject.projTree["0000000000017"].itemStatus == statusKeys[3]
|
||||
assert theProject.tree["0000000000014"].itemStatus == statusKeys[3]
|
||||
assert theProject.tree["0000000000015"].itemStatus == statusKeys[2]
|
||||
assert theProject.tree["0000000000016"].itemStatus == statusKeys[1]
|
||||
assert theProject.tree["0000000000017"].itemStatus == statusKeys[3]
|
||||
|
||||
newList = [
|
||||
{"key": statusKeys[0], "name": "New", "cols": (1, 1, 1)},
|
||||
@@ -723,9 +723,9 @@ def testCoreProject_StatusImport(mockGUI, fncDir, mockRnd):
|
||||
# =================
|
||||
|
||||
fHandle = theProject.newFile("Jane Doe", "8b9d2e465e150")
|
||||
theProject.projTree[fHandle].setImport("Main")
|
||||
theProject.tree[fHandle].setImport("Main")
|
||||
|
||||
assert theProject.projTree[fHandle].itemImport == importKeys[3]
|
||||
assert theProject.tree[fHandle].itemImport == importKeys[3]
|
||||
newList = [
|
||||
{"key": importKeys[0], "name": "New", "cols": (1, 1, 1)},
|
||||
{"key": importKeys[1], "name": "Minor", "cols": (2, 2, 2)},
|
||||
@@ -851,7 +851,7 @@ def testCoreProject_Methods(monkeypatch, mockGUI, tmpDir, fncDir, mockRnd):
|
||||
# Trash folder
|
||||
# Should create on first call, and just returned on later calls
|
||||
hTrash = "0000000000018"
|
||||
assert theProject.projTree[hTrash] is None
|
||||
assert theProject.tree[hTrash] is None
|
||||
assert theProject.trashFolder() == hTrash
|
||||
assert theProject.trashFolder() == hTrash
|
||||
|
||||
@@ -929,11 +929,11 @@ def testCoreProject_Methods(monkeypatch, mockGUI, tmpDir, fncDir, mockRnd):
|
||||
"0000000000010", "0000000000011", "0000000000012",
|
||||
"0000000000016", "0000000000017",
|
||||
]
|
||||
assert theProject.projTree.handles() == oldOrder
|
||||
assert theProject.tree.handles() == oldOrder
|
||||
assert theProject.setTreeOrder(newOrder)
|
||||
assert theProject.projTree.handles() == newOrder
|
||||
assert theProject.tree.handles() == newOrder
|
||||
assert theProject.setTreeOrder(oldOrder)
|
||||
assert theProject.projTree.handles() == oldOrder
|
||||
assert theProject.tree.handles() == oldOrder
|
||||
|
||||
# Session stats
|
||||
theProject.currWCount = 200
|
||||
@@ -1003,7 +1003,7 @@ def testCoreProject_OrphanedFiles(mockGUI, nwLipsum):
|
||||
theProject = NWProject(mockGUI)
|
||||
|
||||
assert theProject.openProject(nwLipsum) is True
|
||||
assert theProject.projTree["636b6aa9b697b"] is None
|
||||
assert theProject.tree["636b6aa9b697b"] is None
|
||||
|
||||
# Add a file with non-existent parent
|
||||
# This file will be renoved from the project on open
|
||||
@@ -1041,11 +1041,11 @@ def testCoreProject_OrphanedFiles(mockGUI, nwLipsum):
|
||||
|
||||
assert theProject.openProject(nwLipsum)
|
||||
assert theProject.projPath is not None
|
||||
assert theProject.projTree["636b6aa9b697bb"] is None
|
||||
assert theProject.projTree["abcdefghijklm"] is None
|
||||
assert theProject.tree["636b6aa9b697bb"] is None
|
||||
assert theProject.tree["abcdefghijklm"] is None
|
||||
|
||||
# First Item with Meta Data
|
||||
oItem = theProject.projTree["636b6aa9b697b"]
|
||||
oItem = theProject.tree["636b6aa9b697b"]
|
||||
assert oItem is not None
|
||||
assert oItem.itemName == "[Recovered] Mars"
|
||||
assert oItem.itemHandle == "636b6aa9b697b"
|
||||
@@ -1055,7 +1055,7 @@ def testCoreProject_OrphanedFiles(mockGUI, nwLipsum):
|
||||
assert oItem.itemLayout == nwItemLayout.NOTE
|
||||
|
||||
# Second Item without Meta Data
|
||||
oItem = theProject.projTree["736b6aa9b697b"]
|
||||
oItem = theProject.tree["736b6aa9b697b"]
|
||||
assert oItem is not None
|
||||
assert oItem.itemName == "Recovered File 1"
|
||||
assert oItem.itemHandle == "736b6aa9b697b"
|
||||
|
||||
Reference in New Issue
Block a user