Also make tree and options properties of the project

This commit is contained in:
Veronica Berglyd Olsen
2022-05-28 14:33:25 +02:00
parent 8bdd09400a
commit 44926a4e9a
28 changed files with 324 additions and 315 deletions
+1 -1
View File
@@ -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)
+16 -16
View File
@@ -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
+25 -25
View File
@@ -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"
+2 -2
View File
@@ -65,9 +65,9 @@ def testDlgItemEditor_Dialog(qtbot, monkeypatch, nwGUI, fncProj, mockRnd):
assert nwGUI.editItem() is False
# Invalid Type
nwGUI.theProject.projTree[tHandle]._type = nwItemType.NO_TYPE
nwGUI.theProject.tree[tHandle]._type = nwItemType.NO_TYPE
assert nwGUI.editItem() is False
nwGUI.theProject.projTree[tHandle]._type = nwItemType.FILE
nwGUI.theProject.tree[tHandle]._type = nwItemType.FILE
# Open Properly
assert nwGUI.editItem() is True
+9 -9
View File
@@ -185,10 +185,10 @@ def testGuiEditor_SaveText(qtbot, monkeypatch, caplog, nwGUI, nwMinimal, ipsumTe
assert "Could not save document." in caplog.text
# Change header level
assert nwGUI.theProject.projTree[sHandle].itemLayout == nwItemLayout.DOCUMENT
assert nwGUI.theProject.tree[sHandle].itemLayout == nwItemLayout.DOCUMENT
nwGUI.docEditor.replaceText(longText[1:])
assert nwGUI.docEditor.saveText() is True
assert nwGUI.theProject.projTree[sHandle].itemLayout == nwItemLayout.DOCUMENT
assert nwGUI.theProject.tree[sHandle].itemLayout == nwItemLayout.DOCUMENT
# Regular save
assert nwGUI.docEditor.saveText() is True
@@ -236,9 +236,9 @@ def testGuiEditor_MetaData(qtbot, monkeypatch, nwGUI, nwMinimal):
assert nwGUI.docEditor.setCursorPosition(None) is False
assert nwGUI.docEditor.setCursorPosition(10) is True
assert nwGUI.docEditor.getCursorPosition() == 10
assert nwGUI.theProject.projTree[sHandle].cursorPos != 10
assert nwGUI.theProject.tree[sHandle].cursorPos != 10
nwGUI.docEditor.saveCursorPosition()
assert nwGUI.theProject.projTree[sHandle].cursorPos == 10
assert nwGUI.theProject.tree[sHandle].cursorPos == 10
assert nwGUI.docEditor.setCursorLine(None) is False
assert nwGUI.docEditor.setCursorLine(2) is True
@@ -1226,8 +1226,8 @@ def testGuiEditor_WordCounters(qtbot, monkeypatch, caplog, nwGUI, nwMinimal, ips
# Open a document and populate it
sHandle = "8c659a11cd429"
nwGUI.theProject.projTree[sHandle]._initCount = 0 # Clear item's count
nwGUI.theProject.projTree[sHandle]._wordCount = 0 # Clear item's count
nwGUI.theProject.tree[sHandle]._initCount = 0 # Clear item's count
nwGUI.theProject.tree[sHandle]._wordCount = 0 # Clear item's count
assert nwGUI.openDocument(sHandle) is True
qtbot.wait(stepDelay)
@@ -1253,9 +1253,9 @@ def testGuiEditor_WordCounters(qtbot, monkeypatch, caplog, nwGUI, nwMinimal, ips
nwGUI.docEditor.wCounterDoc.run()
# nwGUI.docEditor._updateDocCounts(cC, wC, pC)
qtbot.wait(stepDelay)
assert nwGUI.theProject.projTree[sHandle]._charCount == cC
assert nwGUI.theProject.projTree[sHandle]._wordCount == wC
assert nwGUI.theProject.projTree[sHandle]._paraCount == pC
assert nwGUI.theProject.tree[sHandle]._charCount == cC
assert nwGUI.theProject.tree[sHandle]._wordCount == wC
assert nwGUI.theProject.tree[sHandle]._paraCount == pC
assert nwGUI.docEditor.docFooter.wordsText.text() == f"Words: {wC} (+{wC})"
# Select all text
+1 -1
View File
@@ -140,7 +140,7 @@ def testGuiViewer_Main(qtbot, monkeypatch, nwGUI, nwLipsum):
nwGUI.docViewer.reloadText()
# Change document title
nwItem = nwGUI.theProject.projTree["4c4f28287af27"]
nwItem = nwGUI.theProject.tree["4c4f28287af27"]
nwItem.setName("Test Title")
assert nwItem.itemName == "Test Title"
nwGUI.docViewer.updateDocInfo("4c4f28287af27")
+10 -10
View File
@@ -181,10 +181,10 @@ def testGuiMain_Editing(qtbot, monkeypatch, nwGUI, fncProj, refDir, outDir, mock
assert nwGUI.saveProject()
assert nwGUI.closeProject()
assert len(nwGUI.theProject.projTree) == 0
assert len(nwGUI.theProject.projTree._treeOrder) == 0
assert len(nwGUI.theProject.projTree._treeRoots) == 0
assert nwGUI.theProject.projTree.trashRoot() is None
assert len(nwGUI.theProject.tree) == 0
assert len(nwGUI.theProject.tree._treeOrder) == 0
assert len(nwGUI.theProject.tree._treeRoots) == 0
assert nwGUI.theProject.tree.trashRoot() is None
assert nwGUI.theProject.projPath is None
assert nwGUI.theProject.projMeta is None
assert nwGUI.theProject.projFile == "nwProject.nwx"
@@ -208,10 +208,10 @@ def testGuiMain_Editing(qtbot, monkeypatch, nwGUI, fncProj, refDir, outDir, mock
qtbot.wait(stepDelay)
# Check that we loaded the data
assert len(nwGUI.theProject.projTree) == 8
assert len(nwGUI.theProject.projTree._treeOrder) == 8
assert len(nwGUI.theProject.projTree._treeRoots) == 4
assert nwGUI.theProject.projTree.trashRoot() is None
assert len(nwGUI.theProject.tree) == 8
assert len(nwGUI.theProject.tree._treeOrder) == 8
assert len(nwGUI.theProject.tree._treeRoots) == 4
assert nwGUI.theProject.tree.trashRoot() is None
assert nwGUI.theProject.projPath == fncProj
assert nwGUI.theProject.projMeta == os.path.join(fncProj, "meta")
assert nwGUI.theProject.projFile == "nwProject.nwx"
@@ -464,11 +464,11 @@ def testGuiMain_Editing(qtbot, monkeypatch, nwGUI, fncProj, refDir, outDir, mock
# Check a Quick Create and Delete
assert nwGUI.treeView.newTreeItem(nwItemType.FILE, None)
newHandle = nwGUI.treeView.getSelectedHandle()
assert nwGUI.theProject.projTree["0000000000020"] is not None
assert nwGUI.theProject.tree["0000000000020"] is not None
assert nwGUI.treeView.deleteItem()
assert nwGUI.treeView.setSelectedHandle(newHandle)
assert nwGUI.treeView.deleteItem()
assert nwGUI.theProject.projTree["0000000000024"] is not None # Trash
assert nwGUI.theProject.tree["0000000000024"] is not None # Trash
assert nwGUI.saveProject()
# Check the files
+25 -25
View File
@@ -63,7 +63,7 @@ def testGuiProjTree_NewItems(qtbot, caplog, monkeypatch, nwGUI, fncDir, mockRnd)
# Create root item
assert nwTree.newTreeItem(nwItemType.ROOT, nwItemClass.WORLD) is True
assert "0000000000010" in nwGUI.theProject.projTree
assert "0000000000010" in nwGUI.theProject.tree
# File/Folder Items
# =================
@@ -78,42 +78,42 @@ def testGuiProjTree_NewItems(qtbot, caplog, monkeypatch, nwGUI, fncDir, mockRnd)
# Create new folder as child of Novel folder
nwTree.setSelectedHandle("0000000000008")
assert nwTree.newTreeItem(nwItemType.FOLDER) is True
assert nwGUI.theProject.projTree["0000000000011"].itemParent == "0000000000008"
assert nwGUI.theProject.projTree["0000000000011"].itemRoot == "0000000000008"
assert nwGUI.theProject.projTree["0000000000011"].itemClass == nwItemClass.NOVEL
assert nwGUI.theProject.tree["0000000000011"].itemParent == "0000000000008"
assert nwGUI.theProject.tree["0000000000011"].itemRoot == "0000000000008"
assert nwGUI.theProject.tree["0000000000011"].itemClass == nwItemClass.NOVEL
# Add a new file in the new folder
nwTree.setSelectedHandle("0000000000011")
assert nwTree.newTreeItem(nwItemType.FILE) is True
assert nwGUI.theProject.projTree["0000000000012"].itemParent == "0000000000011"
assert nwGUI.theProject.projTree["0000000000012"].itemRoot == "0000000000008"
assert nwGUI.theProject.projTree["0000000000012"].itemClass == nwItemClass.NOVEL
assert nwGUI.theProject.tree["0000000000012"].itemParent == "0000000000011"
assert nwGUI.theProject.tree["0000000000012"].itemRoot == "0000000000008"
assert nwGUI.theProject.tree["0000000000012"].itemClass == nwItemClass.NOVEL
# Add a new file next to the other new file
nwTree.setSelectedHandle("0000000000012")
assert nwTree.newTreeItem(nwItemType.FILE) is True
assert nwGUI.theProject.projTree["0000000000013"].itemParent == "0000000000011"
assert nwGUI.theProject.projTree["0000000000013"].itemRoot == "0000000000008"
assert nwGUI.theProject.projTree["0000000000013"].itemClass == nwItemClass.NOVEL
assert nwGUI.theProject.tree["0000000000013"].itemParent == "0000000000011"
assert nwGUI.theProject.tree["0000000000013"].itemRoot == "0000000000008"
assert nwGUI.theProject.tree["0000000000013"].itemClass == nwItemClass.NOVEL
assert nwGUI.openDocument("0000000000013")
assert nwGUI.docEditor.getText() == "### New Document\n\n"
# Add a new file to the characters folder
nwTree.setSelectedHandle("000000000000a")
assert nwTree.newTreeItem(nwItemType.FILE) is True
assert nwGUI.theProject.projTree["0000000000014"].itemParent == "000000000000a"
assert nwGUI.theProject.projTree["0000000000014"].itemRoot == "000000000000a"
assert nwGUI.theProject.projTree["0000000000014"].itemClass == nwItemClass.CHARACTER
assert nwGUI.theProject.tree["0000000000014"].itemParent == "000000000000a"
assert nwGUI.theProject.tree["0000000000014"].itemRoot == "000000000000a"
assert nwGUI.theProject.tree["0000000000014"].itemClass == nwItemClass.CHARACTER
assert nwGUI.openDocument("0000000000014")
assert nwGUI.docEditor.getText() == "# New Note\n\n"
# Make sure the sibling folder bug trap works
nwTree.setSelectedHandle("0000000000013")
nwGUI.theProject.projTree["0000000000013"].setParent(None) # This should not happen
nwGUI.theProject.tree["0000000000013"].setParent(None) # This should not happen
caplog.clear()
assert nwTree.newTreeItem(nwItemType.FILE) is False
assert "Internal error" in caplog.text
nwGUI.theProject.projTree["0000000000013"].setParent("0000000000011")
nwGUI.theProject.tree["0000000000013"].setParent("0000000000011")
# Get the trash folder
nwTree._addTrashRoot()
@@ -242,22 +242,22 @@ def testGuiProjTree_MoveItems(qtbot, monkeypatch, nwGUI, fncDir, mockRnd):
# ===========
nwTree.setSelectedHandle("0000000000008")
assert nwGUI.theProject.projTree._treeOrder.index("0000000000008") == 0
assert nwGUI.theProject.tree._treeOrder.index("0000000000008") == 0
# Move novel folder up
assert nwTree.moveTreeItem(-1) is False
nwTree.flushTreeOrder()
assert nwGUI.theProject.projTree._treeOrder.index("0000000000008") == 0
assert nwGUI.theProject.tree._treeOrder.index("0000000000008") == 0
# Move novel folder down
assert nwTree.moveTreeItem(1) is True
nwTree.flushTreeOrder()
assert nwGUI.theProject.projTree._treeOrder.index("0000000000008") == 1
assert nwGUI.theProject.tree._treeOrder.index("0000000000008") == 1
# Move novel folder up again
assert nwTree.moveTreeItem(-1) is True
nwTree.flushTreeOrder()
assert nwGUI.theProject.projTree._treeOrder.index("0000000000008") == 0
assert nwGUI.theProject.tree._treeOrder.index("0000000000008") == 0
# Clean up
# qtbot.stopForInteraction()
@@ -341,7 +341,7 @@ def testGuiProjTree_DeleteItems(qtbot, caplog, monkeypatch, nwGUI, fncDir, mockR
"000000000000d", "000000000000e", "000000000000f",
"0000000000010"
]
trashHandle = nwGUI.theProject.projTree.trashRoot()
trashHandle = nwGUI.theProject.tree.trashRoot()
assert nwTree.getTreeFromHandle(trashHandle) == [
trashHandle, "0000000000012", "0000000000011"
]
@@ -349,30 +349,30 @@ def testGuiProjTree_DeleteItems(qtbot, caplog, monkeypatch, nwGUI, fncDir, mockR
# Delete the first file again (permanent), and ask for permission
# Also open the document in the editor, which should trigger a close
assert os.path.isfile(os.path.join(prjDir, "content", "0000000000012.nwd"))
assert "0000000000012" in nwGUI.theProject.projTree
assert "0000000000012" in nwGUI.theProject.tree
assert nwGUI.docEditor.docHandle() is None
assert nwGUI.openDocument("0000000000012") is True
assert nwGUI.docEditor.docHandle() == "0000000000012"
assert nwTree.deleteItem("0000000000012") is True
assert nwGUI.docEditor.docHandle() is None
assert not os.path.isfile(os.path.join(prjDir, "content", "0000000000012.nwd"))
assert "0000000000012" not in nwGUI.theProject.projTree
assert "0000000000012" not in nwGUI.theProject.tree
assert nwTree.getTreeFromHandle(trashHandle) == [
trashHandle, "0000000000011"
]
# Delete the second file, and skip asking for permission
assert os.path.isfile(os.path.join(prjDir, "content", "0000000000011.nwd"))
assert "0000000000011" in nwGUI.theProject.projTree
assert "0000000000011" in nwGUI.theProject.tree
assert nwTree.deleteItem("0000000000011", alreadyAsked=True) is True
assert not os.path.isfile(os.path.join(prjDir, "content", "0000000000011.nwd"))
assert "0000000000011" not in nwGUI.theProject.projTree
assert "0000000000011" not in nwGUI.theProject.tree
assert nwTree.getTreeFromHandle(trashHandle) == [trashHandle]
# Delete Folder
# =============
trashHandle = nwGUI.theProject.projTree.trashRoot()
trashHandle = nwGUI.theProject.tree.trashRoot()
# Add a folder with two files
nwTree.setSelectedHandle("0000000000009")