Fix broken tests
This commit is contained in:
@@ -68,7 +68,7 @@ stopwhenidle = True
|
|||||||
useridletime = 300
|
useridletime = 300
|
||||||
|
|
||||||
[State]
|
[State]
|
||||||
showrefpanel = True
|
showviewerpanel = True
|
||||||
showedittoolbar = False
|
showedittoolbar = False
|
||||||
useshortcodes = False
|
useshortcodes = False
|
||||||
viewcomments = True
|
viewcomments = True
|
||||||
|
|||||||
@@ -68,7 +68,7 @@ stopwhenidle = True
|
|||||||
useridletime = 300
|
useridletime = 300
|
||||||
|
|
||||||
[State]
|
[State]
|
||||||
showrefpanel = True
|
showviewerpanel = True
|
||||||
showedittoolbar = False
|
showedittoolbar = False
|
||||||
useshortcodes = False
|
useshortcodes = False
|
||||||
viewcomments = True
|
viewcomments = True
|
||||||
|
|||||||
@@ -562,11 +562,11 @@ def testCoreIndex_ExtractData(mockGUI, fncPath, mockRnd):
|
|||||||
))
|
))
|
||||||
|
|
||||||
# The novel structure should contain the pointer to the novel file header
|
# The novel structure should contain the pointer to the novel file header
|
||||||
theKeys = []
|
keys = []
|
||||||
for aKey, _, _, _ in index.novelStructure():
|
for aKey, _, _, _ in index.novelStructure():
|
||||||
theKeys.append(aKey)
|
keys.append(aKey)
|
||||||
|
|
||||||
assert theKeys == [
|
assert keys == [
|
||||||
f"{C.hTitlePage}:T0001",
|
f"{C.hTitlePage}:T0001",
|
||||||
f"{C.hChapterDoc}:T0001",
|
f"{C.hChapterDoc}:T0001",
|
||||||
f"{C.hSceneDoc}:T0001",
|
f"{C.hSceneDoc}:T0001",
|
||||||
@@ -576,22 +576,22 @@ def testCoreIndex_ExtractData(mockGUI, fncPath, mockRnd):
|
|||||||
# Check that excluded files can be skipped
|
# Check that excluded files can be skipped
|
||||||
project.tree[nHandle].setActive(False) # type: ignore
|
project.tree[nHandle].setActive(False) # type: ignore
|
||||||
|
|
||||||
theKeys = []
|
keys = []
|
||||||
for aKey, _, _, _ in index.novelStructure(skipExcl=False):
|
for aKey, _, _, _ in index.novelStructure(skipExcl=False):
|
||||||
theKeys.append(aKey)
|
keys.append(aKey)
|
||||||
|
|
||||||
assert theKeys == [
|
assert keys == [
|
||||||
f"{C.hTitlePage}:T0001",
|
f"{C.hTitlePage}:T0001",
|
||||||
f"{C.hChapterDoc}:T0001",
|
f"{C.hChapterDoc}:T0001",
|
||||||
f"{C.hSceneDoc}:T0001",
|
f"{C.hSceneDoc}:T0001",
|
||||||
f"{nHandle}:T0001",
|
f"{nHandle}:T0001",
|
||||||
]
|
]
|
||||||
|
|
||||||
theKeys = []
|
keys = []
|
||||||
for aKey, _, _, _ in index.novelStructure(skipExcl=True):
|
for aKey, _, _, _ in index.novelStructure(skipExcl=True):
|
||||||
theKeys.append(aKey)
|
keys.append(aKey)
|
||||||
|
|
||||||
assert theKeys == [
|
assert keys == [
|
||||||
f"{C.hTitlePage}:T0001",
|
f"{C.hTitlePage}:T0001",
|
||||||
f"{C.hChapterDoc}:T0001",
|
f"{C.hChapterDoc}:T0001",
|
||||||
f"{C.hSceneDoc}:T0001",
|
f"{C.hSceneDoc}:T0001",
|
||||||
@@ -606,23 +606,23 @@ def testCoreIndex_ExtractData(mockGUI, fncPath, mockRnd):
|
|||||||
# getItemData + getHandleHeaderCount
|
# getItemData + getHandleHeaderCount
|
||||||
# ==================================
|
# ==================================
|
||||||
|
|
||||||
theItem = index.getItemData(nHandle)
|
item = index.getItemData(nHandle)
|
||||||
assert isinstance(theItem, IndexItem)
|
assert isinstance(item, IndexItem)
|
||||||
assert theItem.headings() == ["T0001"]
|
assert item.headings() == ["T0001"]
|
||||||
assert index.getHandleHeaderCount(nHandle) == 1
|
assert index.getHandleHeaderCount(nHandle) == 1
|
||||||
|
|
||||||
# getReferences
|
# getReferences
|
||||||
# =============
|
# =============
|
||||||
|
|
||||||
# Look up an invalid handle
|
# Look up an invalid handle
|
||||||
theRefs = index.getReferences("Not a handle")
|
refs = index.getReferences("Not a handle")
|
||||||
assert theRefs["@pov"] == []
|
assert refs["@pov"] == []
|
||||||
assert theRefs["@char"] == []
|
assert refs["@char"] == []
|
||||||
|
|
||||||
# The novel file should now refer to Jane as @pov and @char
|
# The novel file should now refer to Jane as @pov and @char
|
||||||
theRefs = index.getReferences(nHandle)
|
refs = index.getReferences(nHandle)
|
||||||
assert theRefs["@pov"] == ["Jane"]
|
assert refs["@pov"] == ["Jane"]
|
||||||
assert theRefs["@char"] == ["Jane"]
|
assert refs["@char"] == ["Jane"]
|
||||||
|
|
||||||
# getBackReferenceList
|
# getBackReferenceList
|
||||||
# ====================
|
# ====================
|
||||||
@@ -634,8 +634,8 @@ def testCoreIndex_ExtractData(mockGUI, fncPath, mockRnd):
|
|||||||
assert index.getBackReferenceList(C.hTitlePage) == {}
|
assert index.getBackReferenceList(C.hTitlePage) == {}
|
||||||
|
|
||||||
# The character file should have a record of the reference from the novel file
|
# The character file should have a record of the reference from the novel file
|
||||||
theRefs = index.getBackReferenceList(cHandle)
|
refs = index.getBackReferenceList(cHandle)
|
||||||
assert theRefs == {nHandle: "T0001"}
|
assert refs[nHandle][0] == "T0001"
|
||||||
|
|
||||||
# getTagSource
|
# getTagSource
|
||||||
# ============
|
# ============
|
||||||
|
|||||||
@@ -112,7 +112,6 @@ def testGuiViewer_Main(qtbot, monkeypatch, nwGUI, prjLipsum):
|
|||||||
nwGUI.docViewer.setTextCursor(theCursor)
|
nwGUI.docViewer.setTextCursor(theCursor)
|
||||||
nwGUI.docViewer._makeSelection(QTextCursor.WordUnderCursor)
|
nwGUI.docViewer._makeSelection(QTextCursor.WordUnderCursor)
|
||||||
theRect = nwGUI.docViewer.cursorRect()
|
theRect = nwGUI.docViewer.cursorRect()
|
||||||
# qtbot.mouseClick(nwGUI.docViewer.viewport(), Qt.LeftButton, pos=theRect.center(), delay=100)
|
|
||||||
nwGUI.docViewer._linkClicked(QUrl("#char=Bod"))
|
nwGUI.docViewer._linkClicked(QUrl("#char=Bod"))
|
||||||
assert nwGUI.docViewer.docHandle == "4c4f28287af27"
|
assert nwGUI.docViewer.docHandle == "4c4f28287af27"
|
||||||
|
|
||||||
@@ -140,20 +139,6 @@ def testGuiViewer_Main(qtbot, monkeypatch, nwGUI, prjLipsum):
|
|||||||
assert nwGUI.docViewer.docHeader.theTitle.text() == "Test Title"
|
assert nwGUI.docViewer.docHeader.theTitle.text() == "Test Title"
|
||||||
CONFIG.showFullPath = True
|
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
|
# Document footer show/hide synopsis
|
||||||
assert nwGUI.viewDocument("f96ec11c6a3da") is True
|
assert nwGUI.viewDocument("f96ec11c6a3da") is True
|
||||||
assert len(nwGUI.docViewer.toPlainText()) == 4315
|
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.loadText("846352075de7d") is False
|
||||||
assert nwGUI.docViewer.toPlainText() == "An error occurred while generating the preview."
|
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()
|
# qtbot.stop()
|
||||||
|
|
||||||
# END Test testGuiViewer_Main
|
# END Test testGuiViewer_Main
|
||||||
|
|||||||
Reference in New Issue
Block a user