Improve test coverage
This commit is contained in:
@@ -421,6 +421,9 @@ def testCoreTree_Methods(monkeypatch, mockGUI, mockItems):
|
|||||||
assert tree.getItemPath("c000000000001") == [
|
assert tree.getItemPath("c000000000001") == [
|
||||||
"c000000000001", "b000000000001", "a000000000001"
|
"c000000000001", "b000000000001", "a000000000001"
|
||||||
]
|
]
|
||||||
|
assert tree.getItemPath("c000000000001", asName=True) == [
|
||||||
|
"Chapter One", "Act One", "Novel"
|
||||||
|
]
|
||||||
|
|
||||||
# Cause recursion error
|
# Cause recursion error
|
||||||
with monkeypatch.context() as mp:
|
with monkeypatch.context() as mp:
|
||||||
|
|||||||
@@ -55,6 +55,9 @@ def testGuiEditor_Init(qtbot, nwGUI, projPath, ipsumText, mockRnd):
|
|||||||
assert nwGUI.docEditor.verticalScrollBarPolicy() == Qt.ScrollBarAsNeeded
|
assert nwGUI.docEditor.verticalScrollBarPolicy() == Qt.ScrollBarAsNeeded
|
||||||
assert nwGUI.docEditor.horizontalScrollBarPolicy() == Qt.ScrollBarAsNeeded
|
assert nwGUI.docEditor.horizontalScrollBarPolicy() == Qt.ScrollBarAsNeeded
|
||||||
assert nwGUI.docEditor._typPadChar == nwUnicode.U_NBSP
|
assert nwGUI.docEditor._typPadChar == nwUnicode.U_NBSP
|
||||||
|
assert nwGUI.docEditor.docHeader.itemTitle.text() == (
|
||||||
|
"Novel \u203a New Chapter \u203a New Scene"
|
||||||
|
)
|
||||||
|
|
||||||
# Check that editor handles settings
|
# Check that editor handles settings
|
||||||
CONFIG.textFont = ""
|
CONFIG.textFont = ""
|
||||||
@@ -64,6 +67,7 @@ def testGuiEditor_Init(qtbot, nwGUI, projPath, ipsumText, mockRnd):
|
|||||||
CONFIG.hideVScroll = True
|
CONFIG.hideVScroll = True
|
||||||
CONFIG.hideHScroll = True
|
CONFIG.hideHScroll = True
|
||||||
CONFIG.fmtPadThin = True
|
CONFIG.fmtPadThin = True
|
||||||
|
CONFIG.showFullPath = False
|
||||||
|
|
||||||
nwGUI.docEditor.initEditor()
|
nwGUI.docEditor.initEditor()
|
||||||
|
|
||||||
@@ -75,6 +79,29 @@ def testGuiEditor_Init(qtbot, nwGUI, projPath, ipsumText, mockRnd):
|
|||||||
assert nwGUI.docEditor.verticalScrollBarPolicy() == Qt.ScrollBarAlwaysOff
|
assert nwGUI.docEditor.verticalScrollBarPolicy() == Qt.ScrollBarAlwaysOff
|
||||||
assert nwGUI.docEditor.horizontalScrollBarPolicy() == Qt.ScrollBarAlwaysOff
|
assert nwGUI.docEditor.horizontalScrollBarPolicy() == Qt.ScrollBarAlwaysOff
|
||||||
assert nwGUI.docEditor._typPadChar == nwUnicode.U_THNBSP
|
assert nwGUI.docEditor._typPadChar == nwUnicode.U_THNBSP
|
||||||
|
assert nwGUI.docEditor.docHeader.itemTitle.text() == "New Scene"
|
||||||
|
|
||||||
|
# Header
|
||||||
|
# ======
|
||||||
|
|
||||||
|
# Select item from header
|
||||||
|
with qtbot.waitSignal(nwGUI.docEditor.requestProjectItemSelected, timeout=1000) as signal:
|
||||||
|
qtbot.mouseClick(nwGUI.docEditor.docHeader, Qt.MouseButton.LeftButton)
|
||||||
|
assert signal.args == [nwGUI.docEditor.docHeader._docHandle, True]
|
||||||
|
|
||||||
|
# Close from header
|
||||||
|
with qtbot.waitSignal(nwGUI.docEditor.docHeader.closeDocumentRequest, timeout=1000):
|
||||||
|
nwGUI.docEditor.docHeader.closeButton.click()
|
||||||
|
|
||||||
|
assert nwGUI.docEditor.docHeader.tbButton.isVisible() is False
|
||||||
|
assert nwGUI.docEditor.docHeader.searchButton.isVisible() is False
|
||||||
|
assert nwGUI.docEditor.docHeader.closeButton.isVisible() is False
|
||||||
|
assert nwGUI.docEditor.docHeader.minmaxButton.isVisible() is False
|
||||||
|
|
||||||
|
# Select item from header
|
||||||
|
with qtbot.waitSignal(nwGUI.docEditor.requestProjectItemSelected, timeout=1000) as signal:
|
||||||
|
qtbot.mouseClick(nwGUI.docEditor.docHeader, Qt.MouseButton.LeftButton)
|
||||||
|
assert signal.args == ["", True]
|
||||||
|
|
||||||
# qtbot.stop()
|
# qtbot.stop()
|
||||||
|
|
||||||
@@ -82,7 +109,7 @@ def testGuiEditor_Init(qtbot, nwGUI, projPath, ipsumText, mockRnd):
|
|||||||
|
|
||||||
|
|
||||||
@pytest.mark.gui
|
@pytest.mark.gui
|
||||||
def testGuiEditor_LoadText(qtbot, monkeypatch, caplog, nwGUI, projPath, ipsumText, mockRnd):
|
def testGuiEditor_LoadText(qtbot, nwGUI, projPath, ipsumText, mockRnd):
|
||||||
"""Test loading text into the editor."""
|
"""Test loading text into the editor."""
|
||||||
buildTestProject(nwGUI, projPath)
|
buildTestProject(nwGUI, projPath)
|
||||||
assert nwGUI.openDocument(C.hSceneDoc) is True
|
assert nwGUI.openDocument(C.hSceneDoc) is True
|
||||||
@@ -92,9 +119,6 @@ def testGuiEditor_LoadText(qtbot, monkeypatch, caplog, nwGUI, projPath, ipsumTex
|
|||||||
assert nwGUI.saveDocument() is True
|
assert nwGUI.saveDocument() is True
|
||||||
assert nwGUI.closeDocument() is True
|
assert nwGUI.closeDocument() is True
|
||||||
|
|
||||||
# Load Text
|
|
||||||
# =========
|
|
||||||
|
|
||||||
# Invalid handle
|
# Invalid handle
|
||||||
assert nwGUI.docEditor.loadText("abcdefghijklm") is False
|
assert nwGUI.docEditor.loadText("abcdefghijklm") is False
|
||||||
|
|
||||||
@@ -123,9 +147,6 @@ def testGuiEditor_SaveText(qtbot, monkeypatch, caplog, nwGUI, projPath, ipsumTex
|
|||||||
buildTestProject(nwGUI, projPath)
|
buildTestProject(nwGUI, projPath)
|
||||||
assert nwGUI.openDocument(C.hSceneDoc) is True
|
assert nwGUI.openDocument(C.hSceneDoc) is True
|
||||||
|
|
||||||
# Save Text
|
|
||||||
# =========
|
|
||||||
|
|
||||||
longText = "### Lorem Ipsum\n\n%s" % "\n\n".join(ipsumText)
|
longText = "### Lorem Ipsum\n\n%s" % "\n\n".join(ipsumText)
|
||||||
nwGUI.docEditor.replaceText(longText)
|
nwGUI.docEditor.replaceText(longText)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user