Fix existing tests

This commit is contained in:
Veronica Berglyd Olsen
2025-03-23 22:37:16 +01:00
parent 762efedb96
commit 34a3a6e85c
26 changed files with 78 additions and 59 deletions
+22 -7
View File
@@ -30,15 +30,16 @@ from novelwriter import SHARED
from novelwriter.constants import nwFiles
from novelwriter.core.index import Index, TagsIndex
from novelwriter.core.item import NWItem
from novelwriter.core.novelmodel import NovelModel
from novelwriter.core.project import NWProject
from novelwriter.enum import nwComment, nwItemClass, nwItemLayout
from novelwriter.enum import nwComment, nwItemClass, nwItemLayout, nwNovelExtra
from tests.mocked import causeException
from tests.tools import C, buildTestProject, cmpFiles
@pytest.mark.core
def testCoreIndex_LoadSave(qtbot, monkeypatch, prjLipsum, mockGUI, tstPaths):
def testCoreIndex_LoadSave(qtbot, monkeypatch, prjLipsum, nwGUI, tstPaths):
"""Test core functionality of scanning, saving, loading and checking
the index cache file.
"""
@@ -52,6 +53,18 @@ def testCoreIndex_LoadSave(qtbot, monkeypatch, prjLipsum, mockGUI, tstPaths):
index = Index(project)
assert repr(index) == "<Index project='Lorem Ipsum'>"
# Check Novel Model
model = index.getNovelModel("b3643d0f92e32")
assert isinstance(model, NovelModel)
assert model.columns == 3
index.setNovelModelExtraColumn(nwNovelExtra.POV)
index.refreshNovelModel("b3643d0f92e32")
model = index.getNovelModel("b3643d0f92e32")
assert isinstance(model, NovelModel)
assert model.columns == 4
# Re-index
notIndexable = {
"b3643d0f92e32": False, # Novel ROOT
"45e6b01ca35c1": False, # Chapter One FOLDER
@@ -216,7 +229,7 @@ def testCoreIndex_ScanThis(mockGUI):
@pytest.mark.core
def testCoreIndex_CheckThese(mockGUI, fncPath, mockRnd):
def testCoreIndex_CheckThese(nwGUI, fncPath, mockRnd):
"""Test the tag checker function checkThese."""
project = NWProject()
mockRnd.reset()
@@ -338,7 +351,7 @@ def testCoreIndex_CheckThese(mockGUI, fncPath, mockRnd):
@pytest.mark.core
def testCoreIndex_ScanText(monkeypatch, mockGUI, fncPath, mockRnd):
def testCoreIndex_ScanText(monkeypatch, nwGUI, fncPath, mockRnd):
"""Check the index text scanner."""
project = NWProject()
mockRnd.reset()
@@ -586,7 +599,7 @@ def testCoreIndex_ScanText(monkeypatch, mockGUI, fncPath, mockRnd):
@pytest.mark.core
def testCoreIndex_CommentKeys(monkeypatch, mockGUI, fncPath, mockRnd):
def testCoreIndex_CommentKeys(monkeypatch, nwGUI, fncPath, mockRnd):
"""Check the index comment key generator."""
project = NWProject()
mockRnd.reset()
@@ -623,7 +636,7 @@ def testCoreIndex_CommentKeys(monkeypatch, mockGUI, fncPath, mockRnd):
@pytest.mark.core
def testCoreIndex_ExtractData(mockGUI, fncPath, mockRnd):
def testCoreIndex_ExtractData(nwGUI, fncPath, mockRnd):
"""Check the index data extraction functions."""
project = NWProject()
mockRnd.reset()
@@ -755,7 +768,9 @@ def testCoreIndex_ExtractData(mockGUI, fncPath, mockRnd):
# getClassTags
# ============
assert index.getClassTags(None) == ["Jane", "John"]
assert index.getClassTags(nwItemClass.CHARACTER) == ["Jane", "John"]
assert index.getClassTags(nwItemClass.PLOT) == []
# getTagsData
# ===========
@@ -1142,7 +1157,7 @@ def testCoreIndex_TagsIndex():
@pytest.mark.core
def testCoreIndex_ItemIndex(mockGUI, fncPath, mockRnd):
def testCoreIndex_ItemIndex(nwGUI, fncPath, mockRnd):
"""Check the ItemIndex class."""
project = NWProject()
mockRnd.reset()
+6 -6
View File
@@ -155,7 +155,7 @@ def testCoreProjectXML_ReadCurrent(monkeypatch, mockGUI, tstPaths, fncPath):
assert data.getLastHandle("editor") == "636b6aa9b697b"
assert data.getLastHandle("viewer") == "636b6aa9b697b"
assert data.getLastHandle("novelTree") == "7031beac91f75"
assert data.getLastHandle("novel") == "7031beac91f75"
assert data.getLastHandle("outline") == "7031beac91f75"
assert data.itemStatus["sf12341"].name == "New"
@@ -284,7 +284,7 @@ def testCoreProjectXML_ReadLegacy10(tstPaths, fncPath, mockGUI, mockRnd):
assert data.getLastHandle("editor") is None # Dropped by conversion
assert data.getLastHandle("viewer") is None # Dropped by conversion
assert data.getLastHandle("novelTree") is None # Doesn't exist in 1.0
assert data.getLastHandle("novel") is None # Doesn't exist in 1.0
assert data.getLastHandle("outline") is None # Doesn't exist in 1.0
assert data.itemStatus["s000000"].name == "New"
@@ -429,7 +429,7 @@ def testCoreProjectXML_ReadLegacy11(tstPaths, fncPath, mockGUI, mockRnd):
assert data.getLastHandle("editor") is None # Dropped by conversion
assert data.getLastHandle("viewer") is None # Dropped by conversion
assert data.getLastHandle("novelTree") is None # Doesn't exist in 1.1
assert data.getLastHandle("novel") is None # Doesn't exist in 1.1
assert data.getLastHandle("outline") is None # Doesn't exist in 1.1
assert data.itemStatus["s000000"].name == "New"
@@ -574,7 +574,7 @@ def testCoreProjectXML_ReadLegacy12(tstPaths, fncPath, mockGUI, mockRnd):
assert data.getLastHandle("editor") is None # Dropped by conversion
assert data.getLastHandle("viewer") is None # Dropped by conversion
assert data.getLastHandle("novelTree") is None # Doesn't exist in 1.2
assert data.getLastHandle("novel") is None # Doesn't exist in 1.2
assert data.getLastHandle("outline") is None # Doesn't exist in 1.2
assert data.itemStatus["s000000"].name == "New"
@@ -722,7 +722,7 @@ def testCoreProjectXML_ReadLegacy13(tstPaths, fncPath, mockGUI, mockRnd):
assert data.getLastHandle("editor") is None # Dropped by conversion
assert data.getLastHandle("viewer") is None # Dropped by conversion
assert data.getLastHandle("novelTree") is None # Doesn't exist in 1.3
assert data.getLastHandle("novel") is None # Doesn't exist in 1.3
assert data.getLastHandle("outline") is None # Doesn't exist in 1.3
assert data.itemStatus["s000000"].name == "New"
@@ -870,7 +870,7 @@ def testCoreProjectXML_ReadLegacy14(tstPaths, fncPath, mockGUI, mockRnd):
assert data.getLastHandle("editor") is None # Dropped by conversion
assert data.getLastHandle("viewer") is None # Dropped by conversion
assert data.getLastHandle("novelTree") is None # Doesn't exist in 1.3
assert data.getLastHandle("novel") is None # Doesn't exist in 1.3
assert data.getLastHandle("outline") is None # Doesn't exist in 1.3
assert data.itemStatus["sf12341"].name == "New"