Update tests
This commit is contained in:
@@ -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
|
||||
@@ -382,7 +383,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)
|
||||
@@ -396,8 +397,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),
|
||||
@@ -429,6 +440,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() == [
|
||||
|
||||
@@ -31,6 +31,7 @@ from pytestqt.qtbot import QtBot
|
||||
|
||||
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: 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