Merge 2.6.1 release into main
This commit is contained in:
+1
-1
@@ -57,7 +57,7 @@ def resetConfigVars():
|
||||
CONFIG.backupOnClose = False
|
||||
CONFIG._homePath = _TMP_ROOT
|
||||
CONFIG._dLocale = QLocale("en_GB")
|
||||
CONFIG.pdfDocs = _TMP_ROOT / "manual.pdf"
|
||||
CONFIG._manuals = {"manual": _TMP_ROOT / "manual.pdf"}
|
||||
CONFIG.guiLocale = "en_GB"
|
||||
return
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
[Meta]
|
||||
timestamp = 2025-01-26 18:17:44
|
||||
timestamp = 2025-01-29 11:56:34
|
||||
|
||||
[Main]
|
||||
font =
|
||||
@@ -29,6 +29,7 @@ emphlabels = True
|
||||
backuppath =
|
||||
backuponclose = False
|
||||
askbeforebackup = True
|
||||
askbeforeexit = True
|
||||
|
||||
[Editor]
|
||||
textfont =
|
||||
|
||||
@@ -31,6 +31,7 @@ import pytest
|
||||
from novelwriter import CONFIG
|
||||
from novelwriter.config import Config, RecentPaths, RecentProjects
|
||||
from novelwriter.constants import nwFiles
|
||||
from novelwriter.core.project import NWProject
|
||||
|
||||
from tests.mocked import MockApp, causeOSError
|
||||
from tests.tools import cmpFiles, writeFile
|
||||
@@ -294,7 +295,7 @@ def testBaseConfig_Internal(monkeypatch, fncPath):
|
||||
|
||||
|
||||
@pytest.mark.base
|
||||
def testBaseConfig_RecentCache(monkeypatch, tstPaths):
|
||||
def testBaseConfig_RecentCache(monkeypatch, tstPaths, nwGUI):
|
||||
"""Test recent cache file."""
|
||||
cacheFile = tstPaths.cnfDir / nwFiles.RECENT_FILE
|
||||
recent = RecentProjects(CONFIG)
|
||||
@@ -308,8 +309,18 @@ def testBaseConfig_RecentCache(monkeypatch, tstPaths):
|
||||
pathOne = tstPaths.cnfDir / "projPathOne" / nwFiles.PROJ_FILE
|
||||
pathTwo = tstPaths.cnfDir / "projPathTwo" / nwFiles.PROJ_FILE
|
||||
|
||||
recent.update(pathOne, "Proj One", 100, 1600002000)
|
||||
recent.update(pathTwo, "Proj Two", 200, 1600005600)
|
||||
prjOne = NWProject()
|
||||
prjTwo = NWProject()
|
||||
|
||||
prjOne.data.setUuid(None)
|
||||
prjTwo.data.setUuid(None)
|
||||
prjOne.data.setName("Proj One")
|
||||
prjTwo.data.setName("Proj Two")
|
||||
prjOne.data.setCurrCounts(100, 0)
|
||||
prjTwo.data.setCurrCounts(200, 0)
|
||||
|
||||
recent.update(pathOne, prjOne.data, 1600002000)
|
||||
recent.update(pathTwo, prjTwo.data, 1600005600)
|
||||
assert recent.listEntries() == [
|
||||
(str(pathOne), "Proj One", 100, 1600002000),
|
||||
(str(pathTwo), "Proj Two", 200, 1600005600),
|
||||
@@ -341,6 +352,14 @@ def testBaseConfig_RecentCache(monkeypatch, tstPaths):
|
||||
(str(pathTwo), "Proj Two", 200, 1600005600),
|
||||
]
|
||||
|
||||
# Pass Invalid
|
||||
recent.update(None, None, 0) # type: ignore
|
||||
recent.update(None, None, 0) # type: ignore
|
||||
assert recent.listEntries() == [
|
||||
(str(pathOne), "Proj One", 100, 1600002000),
|
||||
(str(pathTwo), "Proj Two", 200, 1600005600),
|
||||
]
|
||||
|
||||
# Remove Non-Existent Entry
|
||||
recent.remove("stuff")
|
||||
assert recent.listEntries() == [
|
||||
|
||||
@@ -188,12 +188,14 @@ def testDlgPreferences_Settings(qtbot, monkeypatch, nwGUI, fncPath, tstPaths):
|
||||
assert CONFIG.showFullPath is True
|
||||
assert CONFIG.incNotesWCount is True
|
||||
|
||||
# Auto Save
|
||||
# Behaviour
|
||||
prefs.autoSaveDoc.stepUp()
|
||||
prefs.autoSaveProj.stepUp()
|
||||
prefs.askBeforeExit.setChecked(False)
|
||||
|
||||
assert CONFIG.autoSaveDoc == 30
|
||||
assert CONFIG.autoSaveProj == 60
|
||||
assert CONFIG.askBeforeExit is True
|
||||
|
||||
# Project Backup
|
||||
with monkeypatch.context() as mp:
|
||||
@@ -341,9 +343,10 @@ def testDlgPreferences_Settings(qtbot, monkeypatch, nwGUI, fncPath, tstPaths):
|
||||
assert CONFIG.showFullPath is False
|
||||
assert CONFIG.incNotesWCount is False
|
||||
|
||||
# Auto Save
|
||||
# Behaviour
|
||||
assert CONFIG.autoSaveDoc == 31
|
||||
assert CONFIG.autoSaveProj == 61
|
||||
assert CONFIG.askBeforeExit is False
|
||||
|
||||
# Project Backup
|
||||
assert CONFIG._backupPath == tstPaths.testDir
|
||||
|
||||
@@ -35,8 +35,8 @@ from novelwriter import CONFIG, SHARED
|
||||
from novelwriter.common import decodeMimeHandles
|
||||
from novelwriter.constants import nwKeyWords, nwUnicode
|
||||
from novelwriter.dialogs.editlabel import GuiEditLabel
|
||||
from novelwriter.enum import nwDocAction, nwDocInsert, nwItemClass, nwItemLayout, nwTrinary
|
||||
from novelwriter.gui.doceditor import GuiDocEditor
|
||||
from novelwriter.enum import nwDocAction, nwDocInsert, nwItemClass, nwItemLayout
|
||||
from novelwriter.gui.doceditor import GuiDocEditor, _TagAction
|
||||
from novelwriter.text.counting import standardCounter
|
||||
from novelwriter.types import (
|
||||
QtAlignJustify, QtAlignLeft, QtKeepAnchor, QtModCtrl, QtModNone,
|
||||
@@ -1699,21 +1699,22 @@ def testGuiEditor_Tags(qtbot, nwGUI, projPath, ipsumText, mockRnd):
|
||||
|
||||
# Empty Block
|
||||
docEditor.setCursorLine(2)
|
||||
assert docEditor._processTag() is nwTrinary.NEUTRAL
|
||||
assert docEditor._processTag() == _TagAction.NONE
|
||||
|
||||
# Not On Tag
|
||||
docEditor.setCursorLine(1)
|
||||
assert docEditor._processTag() is nwTrinary.NEUTRAL
|
||||
assert docEditor._processTag() == _TagAction.NONE
|
||||
|
||||
# On Tag Keyword
|
||||
docEditor.setCursorPosition(15)
|
||||
assert docEditor._processTag() is nwTrinary.NEUTRAL
|
||||
assert docEditor._processTag() == _TagAction.NONE
|
||||
|
||||
# On Known Tag, No Follow
|
||||
docEditor.setCursorPosition(22)
|
||||
assert docEditor._processTag(follow=False) is nwTrinary.POSITIVE
|
||||
assert docEditor._processTag(follow=False) == _TagAction.FOLLOW
|
||||
assert nwGUI.docViewer._docHandle is None
|
||||
|
||||
# qtbot.stop()
|
||||
# On Known Tag, Follow
|
||||
docEditor.setCursorPosition(22)
|
||||
position = QPointF(docEditor.cursorRect().center())
|
||||
@@ -1729,13 +1730,13 @@ def testGuiEditor_Tags(qtbot, nwGUI, projPath, ipsumText, mockRnd):
|
||||
# On Unknown Tag, Create It
|
||||
assert "0000000000011" not in SHARED.project.tree
|
||||
docEditor.setCursorPosition(28)
|
||||
assert docEditor._processTag(create=True) is nwTrinary.NEGATIVE
|
||||
assert docEditor._processTag(create=True) == _TagAction.CREATE
|
||||
assert "0000000000011" in SHARED.project.tree
|
||||
|
||||
# On Unknown Tag, Missing Root
|
||||
assert "0000000000012" not in SHARED.project.tree
|
||||
docEditor.setCursorPosition(42)
|
||||
assert docEditor._processTag(create=True) is nwTrinary.NEGATIVE
|
||||
assert docEditor._processTag(create=True) == _TagAction.CREATE
|
||||
oHandle = SHARED.project.tree.findRoot(nwItemClass.OBJECT)
|
||||
assert oHandle == "0000000000012"
|
||||
|
||||
@@ -1744,7 +1745,7 @@ def testGuiEditor_Tags(qtbot, nwGUI, projPath, ipsumText, mockRnd):
|
||||
assert oItem.itemParent == "0000000000012"
|
||||
|
||||
docEditor.setCursorPosition(47)
|
||||
assert docEditor._processTag() is nwTrinary.NEUTRAL
|
||||
assert docEditor._processTag() == _TagAction.NONE
|
||||
|
||||
# qtbot.stop()
|
||||
|
||||
|
||||
@@ -45,8 +45,8 @@ def testGuiMainMenu_Slots(qtbot, monkeypatch, nwGUI, projPath):
|
||||
with monkeypatch.context() as mp:
|
||||
openUrl = MagicMock()
|
||||
mp.setattr(QDesktopServices, "openUrl", openUrl)
|
||||
CONFIG.pdfDocs = projPath / "manual.pdf"
|
||||
CONFIG.pdfDocs.touch()
|
||||
CONFIG._manuals = {"manual": projPath / "manual.pdf"}
|
||||
CONFIG._manuals["manual"].touch()
|
||||
nwGUI.mainMenu._openUserManualFile()
|
||||
assert openUrl.called is True
|
||||
assert "manual.pdf" in openUrl.call_args[0][0].url()
|
||||
|
||||
@@ -25,7 +25,6 @@ import time
|
||||
import pytest
|
||||
|
||||
from novelwriter import CONFIG, SHARED
|
||||
from novelwriter.enum import nwTrinary
|
||||
|
||||
from tests.tools import C, buildTestProject
|
||||
|
||||
@@ -47,20 +46,20 @@ def testGuiStatusBar_Main(qtbot, monkeypatch, nwGUI, projPath, mockRnd):
|
||||
assert status._refTime == refTime
|
||||
|
||||
# Project Status
|
||||
status.setProjectStatus(nwTrinary.NEUTRAL)
|
||||
assert status.projIcon.state == nwTrinary.NEUTRAL
|
||||
status.setProjectStatus(nwTrinary.NEGATIVE)
|
||||
assert status.projIcon.state == nwTrinary.NEGATIVE
|
||||
status.setProjectStatus(nwTrinary.POSITIVE)
|
||||
assert status.projIcon.state == nwTrinary.POSITIVE
|
||||
status.setProjectStatus(None)
|
||||
assert status.projIcon.state is None
|
||||
status.setProjectStatus(False)
|
||||
assert status.projIcon.state is False
|
||||
status.setProjectStatus(True)
|
||||
assert status.projIcon.state is True
|
||||
|
||||
# Document Status
|
||||
status.setDocumentStatus(nwTrinary.NEUTRAL)
|
||||
assert status.docIcon.state == nwTrinary.NEUTRAL
|
||||
status.setDocumentStatus(nwTrinary.NEGATIVE)
|
||||
assert status.docIcon.state == nwTrinary.NEGATIVE
|
||||
status.setDocumentStatus(nwTrinary.POSITIVE)
|
||||
assert status.docIcon.state == nwTrinary.POSITIVE
|
||||
status.setDocumentStatus(None)
|
||||
assert status.docIcon.state is None
|
||||
status.setDocumentStatus(False)
|
||||
assert status.docIcon.state is False
|
||||
status.setDocumentStatus(True)
|
||||
assert status.docIcon.state is True
|
||||
|
||||
# Idle Status
|
||||
CONFIG.stopWhenIdle = False
|
||||
|
||||
@@ -31,6 +31,7 @@ from PyQt6.QtWidgets import QFileDialog, QMenu
|
||||
|
||||
from novelwriter import CONFIG, SHARED
|
||||
from novelwriter.constants import nwFiles
|
||||
from novelwriter.core.projectdata import NWProjectData
|
||||
from novelwriter.enum import nwItemClass
|
||||
from novelwriter.tools.welcome import GuiWelcome
|
||||
from novelwriter.types import QtMouseLeft
|
||||
@@ -72,8 +73,18 @@ def testToolWelcome_Open(qtbot, monkeypatch, nwGUI, fncPath):
|
||||
monkeypatch.setattr(QMenu, "exec", lambda *a: None)
|
||||
monkeypatch.setattr(QMenu, "setParent", lambda *a: None)
|
||||
|
||||
CONFIG.recentProjects.update("/stuff/project_one", "Project One", 12345, 1690000000)
|
||||
CONFIG.recentProjects.update("/stuff/project_two", "Project Two", 54321, 1700000000)
|
||||
data1 = NWProjectData(SHARED.project)
|
||||
data2 = NWProjectData(SHARED.project)
|
||||
|
||||
data1.setUuid(None)
|
||||
data2.setUuid(None)
|
||||
data1.setName("Project One")
|
||||
data2.setName("Project Two")
|
||||
data1.setCurrCounts(12345, 0)
|
||||
data2.setCurrCounts(54321, 0)
|
||||
|
||||
CONFIG.recentProjects.update("/stuff/project_one", data1, 1690000000)
|
||||
CONFIG.recentProjects.update("/stuff/project_two", data2, 1700000000)
|
||||
dateOne = CONFIG.localDate(datetime.fromtimestamp(1700000000))
|
||||
dateTwo = CONFIG.localDate(datetime.fromtimestamp(1690000000))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user