Fix most tests with minor issues
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user