Fix broken tests

This commit is contained in:
Veronica Berglyd Olsen
2023-11-16 00:23:59 +01:00
parent 3d17d8e08c
commit 844240b5b8
4 changed files with 22 additions and 50 deletions
+1 -1
View File
@@ -68,7 +68,7 @@ stopwhenidle = True
useridletime = 300
[State]
showrefpanel = True
showviewerpanel = True
showedittoolbar = False
useshortcodes = False
viewcomments = True
@@ -68,7 +68,7 @@ stopwhenidle = True
useridletime = 300
[State]
showrefpanel = True
showviewerpanel = True
showedittoolbar = False
useshortcodes = False
viewcomments = True
+20 -20
View File
@@ -562,11 +562,11 @@ def testCoreIndex_ExtractData(mockGUI, fncPath, mockRnd):
))
# The novel structure should contain the pointer to the novel file header
theKeys = []
keys = []
for aKey, _, _, _ in index.novelStructure():
theKeys.append(aKey)
keys.append(aKey)
assert theKeys == [
assert keys == [
f"{C.hTitlePage}:T0001",
f"{C.hChapterDoc}:T0001",
f"{C.hSceneDoc}:T0001",
@@ -576,22 +576,22 @@ def testCoreIndex_ExtractData(mockGUI, fncPath, mockRnd):
# Check that excluded files can be skipped
project.tree[nHandle].setActive(False) # type: ignore
theKeys = []
keys = []
for aKey, _, _, _ in index.novelStructure(skipExcl=False):
theKeys.append(aKey)
keys.append(aKey)
assert theKeys == [
assert keys == [
f"{C.hTitlePage}:T0001",
f"{C.hChapterDoc}:T0001",
f"{C.hSceneDoc}:T0001",
f"{nHandle}:T0001",
]
theKeys = []
keys = []
for aKey, _, _, _ in index.novelStructure(skipExcl=True):
theKeys.append(aKey)
keys.append(aKey)
assert theKeys == [
assert keys == [
f"{C.hTitlePage}:T0001",
f"{C.hChapterDoc}:T0001",
f"{C.hSceneDoc}:T0001",
@@ -606,23 +606,23 @@ def testCoreIndex_ExtractData(mockGUI, fncPath, mockRnd):
# getItemData + getHandleHeaderCount
# ==================================
theItem = index.getItemData(nHandle)
assert isinstance(theItem, IndexItem)
assert theItem.headings() == ["T0001"]
item = index.getItemData(nHandle)
assert isinstance(item, IndexItem)
assert item.headings() == ["T0001"]
assert index.getHandleHeaderCount(nHandle) == 1
# getReferences
# =============
# Look up an invalid handle
theRefs = index.getReferences("Not a handle")
assert theRefs["@pov"] == []
assert theRefs["@char"] == []
refs = index.getReferences("Not a handle")
assert refs["@pov"] == []
assert refs["@char"] == []
# The novel file should now refer to Jane as @pov and @char
theRefs = index.getReferences(nHandle)
assert theRefs["@pov"] == ["Jane"]
assert theRefs["@char"] == ["Jane"]
refs = index.getReferences(nHandle)
assert refs["@pov"] == ["Jane"]
assert refs["@char"] == ["Jane"]
# getBackReferenceList
# ====================
@@ -634,8 +634,8 @@ def testCoreIndex_ExtractData(mockGUI, fncPath, mockRnd):
assert index.getBackReferenceList(C.hTitlePage) == {}
# The character file should have a record of the reference from the novel file
theRefs = index.getBackReferenceList(cHandle)
assert theRefs == {nHandle: "T0001"}
refs = index.getBackReferenceList(cHandle)
assert refs[nHandle][0] == "T0001"
# getTagSource
# ============
-28
View File
@@ -112,7 +112,6 @@ def testGuiViewer_Main(qtbot, monkeypatch, nwGUI, prjLipsum):
nwGUI.docViewer.setTextCursor(theCursor)
nwGUI.docViewer._makeSelection(QTextCursor.WordUnderCursor)
theRect = nwGUI.docViewer.cursorRect()
# qtbot.mouseClick(nwGUI.docViewer.viewport(), Qt.LeftButton, pos=theRect.center(), delay=100)
nwGUI.docViewer._linkClicked(QUrl("#char=Bod"))
assert nwGUI.docViewer.docHandle == "4c4f28287af27"
@@ -140,20 +139,6 @@ def testGuiViewer_Main(qtbot, monkeypatch, nwGUI, prjLipsum):
assert nwGUI.docViewer.docHeader.theTitle.text() == "Test Title"
CONFIG.showFullPath = True
# Document footer show/hide references
viewState = nwGUI.viewMeta.isVisible()
nwGUI.docViewer.docFooter._doShowHide()
assert nwGUI.viewMeta.isVisible() is not viewState
nwGUI.docViewer.docFooter._doShowHide()
assert nwGUI.viewMeta.isVisible() is viewState
# Document footer sticky
viewState = nwGUI.docViewer.stickyRef
nwGUI.docViewer.docFooter._doToggleSticky(not viewState)
assert nwGUI.docViewer.stickyRef is not viewState
nwGUI.docViewer.docFooter._doToggleSticky(viewState)
assert nwGUI.docViewer.stickyRef is viewState
# Document footer show/hide synopsis
assert nwGUI.viewDocument("f96ec11c6a3da") is True
assert len(nwGUI.docViewer.toPlainText()) == 4315
@@ -172,19 +157,6 @@ def testGuiViewer_Main(qtbot, monkeypatch, nwGUI, prjLipsum):
assert nwGUI.docViewer.loadText("846352075de7d") is False
assert nwGUI.docViewer.toPlainText() == "An error occurred while generating the preview."
# Check reference panel (issue #1378)
assert nwGUI.viewDocument("4c4f28287af27") is True
assert nwGUI.docViewer.toPlainText().startswith("Nobody Owens")
nwGUI.viewMeta._linkClicked("fb609cd8319dc")
assert nwGUI.docViewer.toPlainText().startswith("Chapter One")
nwGUI.viewMeta._linkClicked("88243afbe5ed8#T0001")
assert nwGUI.docViewer.toPlainText().startswith("Scene One")
nwGUI.viewMeta._linkClicked("88243afbe5ed8#ABCD")
assert nwGUI.docViewer.toPlainText().startswith("Scene One")
# qtbot.stop()
# END Test testGuiViewer_Main