|
|
@@ -14,7 +14,7 @@ from os import path
|
|
|
|
from PyQt5.QtCore import Qt, QItemSelectionModel
|
|
|
|
from PyQt5.QtCore import Qt, QItemSelectionModel
|
|
|
|
from PyQt5.QtWidgets import (
|
|
|
|
from PyQt5.QtWidgets import (
|
|
|
|
QDialogButtonBox, QTreeWidgetItem, QListWidgetItem, QDialog, QAction,
|
|
|
|
QDialogButtonBox, QTreeWidgetItem, QListWidgetItem, QDialog, QAction,
|
|
|
|
QMessageBox, QFileDialog
|
|
|
|
QMessageBox, QFileDialog, QFontDialog
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
from nw.gui import (
|
|
|
|
from nw.gui import (
|
|
|
@@ -198,7 +198,7 @@ def testItemEditor(qtbot, yesToAll, nwFuncTemp, nwTempGUI, nwRef, nwTemp):
|
|
|
|
# qtbot.stopForInteraction()
|
|
|
|
# qtbot.stopForInteraction()
|
|
|
|
|
|
|
|
|
|
|
|
@pytest.mark.gui
|
|
|
|
@pytest.mark.gui
|
|
|
|
def testWritingStatsExport(qtbot, yesToAll, nwFuncTemp, nwTemp):
|
|
|
|
def testWritingStatsExport(qtbot, monkeypatch, yesToAll, nwFuncTemp, nwTemp):
|
|
|
|
nwGUI = nw.main(["--testmode", "--config=%s" % nwFuncTemp, "--data=%s" % nwTemp])
|
|
|
|
nwGUI = nw.main(["--testmode", "--config=%s" % nwFuncTemp, "--data=%s" % nwTemp])
|
|
|
|
qtbot.addWidget(nwGUI)
|
|
|
|
qtbot.addWidget(nwGUI)
|
|
|
|
nwGUI.show()
|
|
|
|
nwGUI.show()
|
|
|
@@ -263,6 +263,10 @@ def testWritingStatsExport(qtbot, yesToAll, nwFuncTemp, nwTemp):
|
|
|
|
assert isinstance(sessLog, GuiWritingStats)
|
|
|
|
assert isinstance(sessLog, GuiWritingStats)
|
|
|
|
qtbot.wait(stepDelay)
|
|
|
|
qtbot.wait(stepDelay)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
monkeypatch.setattr(QFileDialog, "getSaveFileName", lambda *args, **kwargs: [])
|
|
|
|
|
|
|
|
assert not sessLog._saveData(sessLog.FMT_CSV)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
monkeypatch.setattr(QFileDialog, "getSaveFileName", lambda ss, tt, pp, options: [pp])
|
|
|
|
assert sessLog._saveData(sessLog.FMT_CSV)
|
|
|
|
assert sessLog._saveData(sessLog.FMT_CSV)
|
|
|
|
qtbot.wait(stepDelay)
|
|
|
|
qtbot.wait(stepDelay)
|
|
|
|
assert sessLog._saveData(sessLog.FMT_JSON)
|
|
|
|
assert sessLog._saveData(sessLog.FMT_JSON)
|
|
|
@@ -913,9 +917,16 @@ def testLoadProject(qtbot, monkeypatch, yesToAll, nwMinimal, nwTemp):
|
|
|
|
nwLoad._keyPressDelete()
|
|
|
|
nwLoad._keyPressDelete()
|
|
|
|
assert nwLoad.listBox.topLevelItemCount() == recentCount - 1
|
|
|
|
assert nwLoad.listBox.topLevelItemCount() == recentCount - 1
|
|
|
|
|
|
|
|
|
|
|
|
nwLoad.close()
|
|
|
|
getFile = path.join(nwMinimal, "nwProject.nwx")
|
|
|
|
|
|
|
|
monkeypatch.setattr(QFileDialog, "getOpenFileName", lambda *args, **kwargs: (getFile, None))
|
|
|
|
|
|
|
|
qtbot.mouseClick(nwLoad.browseButton, Qt.LeftButton)
|
|
|
|
|
|
|
|
assert nwLoad.openPath == nwMinimal
|
|
|
|
|
|
|
|
assert nwLoad.openState == nwLoad.OPEN_STATE
|
|
|
|
# qtbot.stopForInteraction()
|
|
|
|
# qtbot.stopForInteraction()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
nwLoad.close()
|
|
|
|
nwGUI.closeMain()
|
|
|
|
nwGUI.closeMain()
|
|
|
|
|
|
|
|
nwGUI.close()
|
|
|
|
|
|
|
|
|
|
|
|
@pytest.mark.gui
|
|
|
|
@pytest.mark.gui
|
|
|
|
def testPreferences(qtbot, monkeypatch, yesToAll, nwMinimal, nwTemp, nwRef, tmpConf):
|
|
|
|
def testPreferences(qtbot, monkeypatch, yesToAll, nwMinimal, nwTemp, nwRef, tmpConf):
|
|
|
@@ -927,8 +938,6 @@ def testPreferences(qtbot, monkeypatch, yesToAll, nwMinimal, nwTemp, nwRef, tmpC
|
|
|
|
|
|
|
|
|
|
|
|
assert nwGUI.openProject(nwMinimal)
|
|
|
|
assert nwGUI.openProject(nwMinimal)
|
|
|
|
|
|
|
|
|
|
|
|
monkeypatch.setattr(QMessageBox, "information", lambda *args, **kwargs: None)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
monkeypatch.setattr(GuiPreferences, "exec_", lambda *args: None)
|
|
|
|
monkeypatch.setattr(GuiPreferences, "exec_", lambda *args: None)
|
|
|
|
monkeypatch.setattr(GuiPreferences, "result", lambda *args: QDialog.Accepted)
|
|
|
|
monkeypatch.setattr(GuiPreferences, "result", lambda *args: QDialog.Accepted)
|
|
|
|
nwGUI.mainMenu.aPreferences.activate(QAction.Trigger)
|
|
|
|
nwGUI.mainMenu.aPreferences.activate(QAction.Trigger)
|
|
|
@@ -952,7 +961,7 @@ def testPreferences(qtbot, monkeypatch, yesToAll, nwMinimal, nwTemp, nwRef, tmpC
|
|
|
|
qtbot.wait(keyDelay)
|
|
|
|
qtbot.wait(keyDelay)
|
|
|
|
tabGeneral = nwPrefs.tabGeneral
|
|
|
|
tabGeneral = nwPrefs.tabGeneral
|
|
|
|
nwPrefs._tabBox.setCurrentWidget(tabGeneral)
|
|
|
|
nwPrefs._tabBox.setCurrentWidget(tabGeneral)
|
|
|
|
tabGeneral.backupPath = nwTemp
|
|
|
|
tabGeneral.backupPath = "no/where"
|
|
|
|
|
|
|
|
|
|
|
|
qtbot.wait(keyDelay)
|
|
|
|
qtbot.wait(keyDelay)
|
|
|
|
assert not tabGeneral.preferDarkIcons.isChecked()
|
|
|
|
assert not tabGeneral.preferDarkIcons.isChecked()
|
|
|
@@ -964,6 +973,16 @@ def testPreferences(qtbot, monkeypatch, yesToAll, nwMinimal, nwTemp, nwRef, tmpC
|
|
|
|
qtbot.mouseClick(tabGeneral.showFullPath, Qt.LeftButton)
|
|
|
|
qtbot.mouseClick(tabGeneral.showFullPath, Qt.LeftButton)
|
|
|
|
assert not tabGeneral.showFullPath.isChecked()
|
|
|
|
assert not tabGeneral.showFullPath.isChecked()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Check Browse button
|
|
|
|
|
|
|
|
monkeypatch.setattr(QFileDialog, "getExistingDirectory", lambda *args, **kwargs: "")
|
|
|
|
|
|
|
|
assert not tabGeneral._backupFolder()
|
|
|
|
|
|
|
|
monkeypatch.setattr(QFileDialog, "getExistingDirectory", lambda *args, **kwargs: "some/dir")
|
|
|
|
|
|
|
|
qtbot.mouseClick(tabGeneral.backupGetPath, Qt.LeftButton)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Check font button
|
|
|
|
|
|
|
|
monkeypatch.setattr(QFontDialog, "getFont", lambda font, obj: (font, True))
|
|
|
|
|
|
|
|
qtbot.mouseClick(tabGeneral.fontButton, Qt.LeftButton)
|
|
|
|
|
|
|
|
|
|
|
|
qtbot.wait(keyDelay)
|
|
|
|
qtbot.wait(keyDelay)
|
|
|
|
assert not tabGeneral.backupOnClose.isChecked()
|
|
|
|
assert not tabGeneral.backupOnClose.isChecked()
|
|
|
|
qtbot.mouseClick(tabGeneral.backupOnClose, Qt.LeftButton)
|
|
|
|
qtbot.mouseClick(tabGeneral.backupOnClose, Qt.LeftButton)
|
|
|
@@ -979,6 +998,9 @@ def testPreferences(qtbot, monkeypatch, yesToAll, nwMinimal, nwTemp, nwRef, tmpC
|
|
|
|
tabLayout = nwPrefs.tabLayout
|
|
|
|
tabLayout = nwPrefs.tabLayout
|
|
|
|
nwPrefs._tabBox.setCurrentWidget(tabLayout)
|
|
|
|
nwPrefs._tabBox.setCurrentWidget(tabLayout)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
qtbot.wait(keyDelay)
|
|
|
|
|
|
|
|
qtbot.mouseClick(tabLayout.fontButton, Qt.LeftButton)
|
|
|
|
|
|
|
|
|
|
|
|
qtbot.wait(keyDelay)
|
|
|
|
qtbot.wait(keyDelay)
|
|
|
|
tabLayout.textStyleSize.setValue(13)
|
|
|
|
tabLayout.textStyleSize.setValue(13)
|
|
|
|
tabLayout.textFlowMax.setValue(700)
|
|
|
|
tabLayout.textFlowMax.setValue(700)
|
|
|
@@ -1050,12 +1072,14 @@ def testPreferences(qtbot, monkeypatch, yesToAll, nwMinimal, nwTemp, nwRef, tmpC
|
|
|
|
assert not tabAutoRep.autoReplaceDash.isEnabled()
|
|
|
|
assert not tabAutoRep.autoReplaceDash.isEnabled()
|
|
|
|
assert not tabAutoRep.autoReplaceDots.isEnabled()
|
|
|
|
assert not tabAutoRep.autoReplaceDots.isEnabled()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
monkeypatch.setattr(QuotesDialog, "selectedQuote", "'")
|
|
|
|
|
|
|
|
monkeypatch.setattr(QuotesDialog, "exec_", lambda *args: QDialog.Accepted)
|
|
|
|
|
|
|
|
qtbot.mouseClick(tabAutoRep.btnDoubleStyleC, Qt.LeftButton)
|
|
|
|
|
|
|
|
|
|
|
|
# Save and Check Config
|
|
|
|
# Save and Check Config
|
|
|
|
qtbot.mouseClick(nwPrefs.buttonBox.button(QDialogButtonBox.Ok), Qt.LeftButton)
|
|
|
|
qtbot.mouseClick(nwPrefs.buttonBox.button(QDialogButtonBox.Ok), Qt.LeftButton)
|
|
|
|
|
|
|
|
|
|
|
|
assert tmpConf.confChanged
|
|
|
|
assert tmpConf.confChanged
|
|
|
|
assert tmpConf.backupPath == nwTemp
|
|
|
|
|
|
|
|
tmpConf.backupPath = ""
|
|
|
|
|
|
|
|
tmpConf.lastPath = ""
|
|
|
|
tmpConf.lastPath = ""
|
|
|
|
|
|
|
|
|
|
|
|
assert nwGUI.mainConf.saveConfig()
|
|
|
|
assert nwGUI.mainConf.saveConfig()
|
|
|
@@ -1070,7 +1094,7 @@ def testPreferences(qtbot, monkeypatch, yesToAll, nwMinimal, nwTemp, nwRef, tmpC
|
|
|
|
ignoreLines = [
|
|
|
|
ignoreLines = [
|
|
|
|
2, # Timestamp
|
|
|
|
2, # Timestamp
|
|
|
|
11, 12, 13, 14, 15, 16, 17, # Window sizes
|
|
|
|
11, 12, 13, 14, 15, 16, 17, # Window sizes
|
|
|
|
7, 25, # Fonts (depends in system default)
|
|
|
|
7, 25, # Fonts (depends on system default)
|
|
|
|
]
|
|
|
|
]
|
|
|
|
assert cmpFiles(testConf, refConf, ignoreLines)
|
|
|
|
assert cmpFiles(testConf, refConf, ignoreLines)
|
|
|
|
|
|
|
|
|
|
|
|