Add tests using the Qt model tester

This commit is contained in:
Veronica Berglyd Olsen
2025-05-08 21:15:55 +02:00
parent 7c15b76c8c
commit 307965a464
2 changed files with 18 additions and 1 deletions
+10 -1
View File
@@ -23,11 +23,12 @@ from __future__ import annotations
import pytest
from PyQt6.QtCore import QMimeData, QModelIndex, Qt
from PyQt6.QtTest import QAbstractItemModelTester
from novelwriter.common import decodeMimeHandles
from novelwriter.constants import nwConst
from novelwriter.core.item import NWItem
from novelwriter.core.itemmodel import INV_ROOT, NODE_FLAGS, ProjectNode
from novelwriter.core.itemmodel import INV_ROOT, NODE_FLAGS, ProjectModel, ProjectNode
from novelwriter.core.project import NWProject
from novelwriter.enum import nwItemLayout, nwItemType
@@ -253,6 +254,14 @@ def testCoreItemModel_ProjectNode_Data(mockGUI, mockRnd, fncPath):
assert scene.flags() == NODE_FLAGS | Qt.ItemFlag.ItemIsDragEnabled
@pytest.mark.core
def testCoreItemModel_ProjectModel_ModelTest(mockGUI):
"""Run the Qt model tester on the model."""
project = NWProject()
model = ProjectModel(project.tree)
QAbstractItemModelTester(model)
@pytest.mark.core
def testCoreItemModel_ProjectModel_Interface(mockGUI, mockRnd, fncPath):
"""Test the model interface for the project model."""
+8
View File
@@ -23,6 +23,7 @@ from __future__ import annotations
import pytest
from PyQt6.QtCore import QModelIndex, Qt
from PyQt6.QtTest import QAbstractItemModelTester
from novelwriter.core.indexdata import IndexHeading
from novelwriter.core.novelmodel import NovelModel
@@ -32,6 +33,13 @@ from novelwriter.enum import nwNovelExtra
from tests.tools import C, buildTestProject
@pytest.mark.core
def testCoreNovelModel_ModelTest(nwGUI):
"""Run the Qt model tester on the model."""
model = NovelModel()
QAbstractItemModelTester(model)
@pytest.mark.core
def testCoreNovelModel_Interface(nwGUI, fncPath, mockRnd):
"""Test the novel model interface."""