Update tests
This commit is contained in:
@@ -27,10 +27,10 @@ from PyQt5.QtGui import QFont, QFontDatabase, QKeyEvent
|
|||||||
from PyQt5.QtWidgets import QAction, QFileDialog, QFontDialog
|
from PyQt5.QtWidgets import QAction, QFileDialog, QFontDialog
|
||||||
|
|
||||||
from novelwriter import CONFIG, SHARED
|
from novelwriter import CONFIG, SHARED
|
||||||
from novelwriter.constants import nwConst, nwUnicode
|
from novelwriter.constants import nwUnicode
|
||||||
from novelwriter.dialogs.preferences import GuiPreferences
|
from novelwriter.dialogs.preferences import GuiPreferences
|
||||||
from novelwriter.dialogs.quotes import GuiQuoteSelect
|
from novelwriter.dialogs.quotes import GuiQuoteSelect
|
||||||
from novelwriter.types import QtDialogApply, QtDialogClose, QtDialogSave, QtModeNone
|
from novelwriter.types import QtDialogApply, QtDialogClose, QtDialogSave, QtModNone
|
||||||
|
|
||||||
KEY_DELAY = 1
|
KEY_DELAY = 1
|
||||||
|
|
||||||
@@ -125,23 +125,19 @@ def testDlgPreferences_Actions(qtbot, monkeypatch, nwGUI):
|
|||||||
# Check Save Button
|
# Check Save Button
|
||||||
prefs.show()
|
prefs.show()
|
||||||
with qtbot.waitSignal(prefs.newPreferencesReady) as signal:
|
with qtbot.waitSignal(prefs.newPreferencesReady) as signal:
|
||||||
with qtbot.waitSignal(prefs.finished) as status:
|
prefs.buttonBox.button(QtDialogSave).click()
|
||||||
prefs.buttonBox.button(QtDialogSave).click()
|
assert signal.args == [False, False, False, False]
|
||||||
assert signal.args == [False, False, False, False]
|
|
||||||
assert status.args == [nwConst.DLG_FINISHED]
|
|
||||||
|
|
||||||
# Check Close Button
|
# Check Close Button
|
||||||
prefs.show()
|
prefs.show()
|
||||||
with qtbot.waitSignal(prefs.finished) as status:
|
prefs.buttonBox.button(QtDialogClose).click()
|
||||||
prefs.buttonBox.button(QtDialogClose).click()
|
assert prefs.isHidden() is True
|
||||||
assert status.args == [nwConst.DLG_FINISHED]
|
|
||||||
|
|
||||||
# Close Using Escape Key
|
# Close Using Escape Key
|
||||||
prefs.show()
|
prefs.show()
|
||||||
with qtbot.waitSignal(prefs.finished) as status:
|
event = QKeyEvent(QEvent.Type.KeyPress, Qt.Key.Key_Escape, QtModNone)
|
||||||
event = QKeyEvent(QEvent.Type.KeyPress, Qt.Key.Key_Escape, QtModeNone)
|
prefs.keyPressEvent(event)
|
||||||
prefs.keyPressEvent(event)
|
assert prefs.isHidden() is True
|
||||||
assert status.args == [nwConst.DLG_FINISHED]
|
|
||||||
|
|
||||||
# qtbot.stop()
|
# qtbot.stop()
|
||||||
|
|
||||||
@@ -299,16 +295,16 @@ def testDlgPreferences_Settings(qtbot, monkeypatch, nwGUI, tstPaths):
|
|||||||
# Quotation Style
|
# Quotation Style
|
||||||
with monkeypatch.context() as mp:
|
with monkeypatch.context() as mp:
|
||||||
mp.setattr(GuiQuoteSelect, "getQuote", lambda *a, **k: (nwUnicode.U_LSAQUO, True))
|
mp.setattr(GuiQuoteSelect, "getQuote", lambda *a, **k: (nwUnicode.U_LSAQUO, True))
|
||||||
prefs.btnSingleStyleO.click()
|
prefs.btnSQuoteOpen.click()
|
||||||
with monkeypatch.context() as mp:
|
with monkeypatch.context() as mp:
|
||||||
mp.setattr(GuiQuoteSelect, "getQuote", lambda *a, **k: (nwUnicode.U_RSAQUO, True))
|
mp.setattr(GuiQuoteSelect, "getQuote", lambda *a, **k: (nwUnicode.U_RSAQUO, True))
|
||||||
prefs.btnSingleStyleC.click()
|
prefs.btnSQuoteClose.click()
|
||||||
with monkeypatch.context() as mp:
|
with monkeypatch.context() as mp:
|
||||||
mp.setattr(GuiQuoteSelect, "getQuote", lambda *a, **k: (nwUnicode.U_LAQUO, True))
|
mp.setattr(GuiQuoteSelect, "getQuote", lambda *a, **k: (nwUnicode.U_LAQUO, True))
|
||||||
prefs.btnDoubleStyleO.click()
|
prefs.btnDQuoteOpen.click()
|
||||||
with monkeypatch.context() as mp:
|
with monkeypatch.context() as mp:
|
||||||
mp.setattr(GuiQuoteSelect, "getQuote", lambda *a, **k: (nwUnicode.U_RAQUO, True))
|
mp.setattr(GuiQuoteSelect, "getQuote", lambda *a, **k: (nwUnicode.U_RAQUO, True))
|
||||||
prefs.btnDoubleStyleC.click()
|
prefs.btnDQuoteClose.click()
|
||||||
|
|
||||||
assert CONFIG.fmtSQuoteOpen == nwUnicode.U_LSQUO
|
assert CONFIG.fmtSQuoteOpen == nwUnicode.U_LSQUO
|
||||||
assert CONFIG.fmtSQuoteClose == nwUnicode.U_RSQUO
|
assert CONFIG.fmtSQuoteClose == nwUnicode.U_RSQUO
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ from novelwriter import CONFIG, SHARED
|
|||||||
from novelwriter.core.toqdoc import ToQTextDocument
|
from novelwriter.core.toqdoc import ToQTextDocument
|
||||||
from novelwriter.enum import nwDocAction
|
from novelwriter.enum import nwDocAction
|
||||||
from novelwriter.gui.docviewer import GuiDocViewer
|
from novelwriter.gui.docviewer import GuiDocViewer
|
||||||
from novelwriter.types import QtModeNone, QtMouseLeft
|
from novelwriter.types import QtModNone, QtMouseLeft
|
||||||
|
|
||||||
from tests.mocked import causeException
|
from tests.mocked import causeException
|
||||||
|
|
||||||
@@ -61,7 +61,7 @@ def testGuiViewer_Main(qtbot, monkeypatch, nwGUI, prjLipsum):
|
|||||||
|
|
||||||
# Re-select via header click
|
# Re-select via header click
|
||||||
button = QtMouseLeft
|
button = QtMouseLeft
|
||||||
modifier = QtModeNone
|
modifier = QtModNone
|
||||||
event = QMouseEvent(QEvent.Type.MouseButtonPress, QPoint(), button, button, modifier)
|
event = QMouseEvent(QEvent.Type.MouseButtonPress, QPoint(), button, button, modifier)
|
||||||
docViewer.docHeader.mousePressEvent(event)
|
docViewer.docHeader.mousePressEvent(event)
|
||||||
assert nwGUI.projView.projTree.getSelectedHandle() == "88243afbe5ed8"
|
assert nwGUI.projView.projTree.getSelectedHandle() == "88243afbe5ed8"
|
||||||
|
|||||||
@@ -400,7 +400,7 @@ def testGuiMainMenu_Insert(qtbot, monkeypatch, nwGUI, fncPath, projPath, mockRnd
|
|||||||
nwGUI.docEditor.clear()
|
nwGUI.docEditor.clear()
|
||||||
|
|
||||||
nwGUI.mainMenu.aInsMSApos.activate(QAction.Trigger)
|
nwGUI.mainMenu.aInsMSApos.activate(QAction.Trigger)
|
||||||
assert nwGUI.docEditor.getText() == nwUnicode.U_MAPOSS
|
assert nwGUI.docEditor.getText() == nwUnicode.U_MAPOS
|
||||||
nwGUI.docEditor.clear()
|
nwGUI.docEditor.clear()
|
||||||
|
|
||||||
nwGUI.mainMenu.aInsEllipsis.activate(QAction.Trigger)
|
nwGUI.mainMenu.aInsEllipsis.activate(QAction.Trigger)
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ from novelwriter.dialogs.editlabel import GuiEditLabel
|
|||||||
from novelwriter.enum import nwItemClass, nwItemLayout, nwItemType, nwWidget
|
from novelwriter.enum import nwItemClass, nwItemLayout, nwItemType, nwWidget
|
||||||
from novelwriter.gui.projtree import GuiProjectTree, GuiProjectView, _TreeContextMenu
|
from novelwriter.gui.projtree import GuiProjectTree, GuiProjectView, _TreeContextMenu
|
||||||
from novelwriter.guimain import GuiMain
|
from novelwriter.guimain import GuiMain
|
||||||
from novelwriter.types import QtAccepted, QtModeNone, QtMouseLeft, QtMouseMiddle, QtRejected
|
from novelwriter.types import QtAccepted, QtModNone, QtMouseLeft, QtMouseMiddle, QtRejected
|
||||||
|
|
||||||
from tests.mocked import causeOSError
|
from tests.mocked import causeOSError
|
||||||
from tests.tools import C, buildTestProject
|
from tests.tools import C, buildTestProject
|
||||||
@@ -807,7 +807,7 @@ def testGuiProjTree_AutoScroll(qtbot, monkeypatch, nwGUI: GuiMain, projPath, moc
|
|||||||
action = Qt.DropAction.MoveAction
|
action = Qt.DropAction.MoveAction
|
||||||
mime = QMimeData()
|
mime = QMimeData()
|
||||||
mouse = QtMouseLeft
|
mouse = QtMouseLeft
|
||||||
modifier = QtModeNone
|
modifier = QtModNone
|
||||||
|
|
||||||
# Scroll Down
|
# Scroll Down
|
||||||
h = projTree.height()
|
h = projTree.height()
|
||||||
@@ -864,7 +864,7 @@ def testGuiProjTree_DragAndDrop(qtbot, monkeypatch, caplog, nwGUI: GuiMain, proj
|
|||||||
action = Qt.DropAction.MoveAction
|
action = Qt.DropAction.MoveAction
|
||||||
mime = QMimeData()
|
mime = QMimeData()
|
||||||
mouse = QtMouseLeft
|
mouse = QtMouseLeft
|
||||||
modifier = QtModeNone
|
modifier = QtModNone
|
||||||
|
|
||||||
projTree.saveTreeOrder()
|
projTree.saveTreeOrder()
|
||||||
treeOrder = SHARED.project.tree._order
|
treeOrder = SHARED.project.tree._order
|
||||||
@@ -1064,7 +1064,7 @@ def testGuiProjTree_Other(qtbot, monkeypatch, nwGUI: GuiMain, projPath, mockRnd)
|
|||||||
eType = QEvent.Type.MouseButtonPress
|
eType = QEvent.Type.MouseButtonPress
|
||||||
pos = projTree.visualItemRect(projTree._getTreeItem(C.hChapterDoc)).center()
|
pos = projTree.visualItemRect(projTree._getTreeItem(C.hChapterDoc)).center()
|
||||||
button = QtMouseMiddle
|
button = QtMouseMiddle
|
||||||
modifier = QtModeNone
|
modifier = QtModNone
|
||||||
|
|
||||||
# Trigger the viewer
|
# Trigger the viewer
|
||||||
event = QMouseEvent(eType, pos, button, button, modifier)
|
event = QMouseEvent(eType, pos, button, button, modifier)
|
||||||
|
|||||||
Reference in New Issue
Block a user