Use storage class to return document objects

This commit is contained in:
Veronica Berglyd Olsen
2022-11-06 00:29:43 +01:00
parent 76a1421fde
commit a75424e44b
14 changed files with 36 additions and 46 deletions
+3 -4
View File
@@ -29,7 +29,6 @@ from PyQt5.QtCore import Qt
from PyQt5.QtWidgets import QMessageBox, QMenu, QTreeWidgetItem, QDialog
from novelwriter.enum import nwItemLayout, nwItemType, nwItemClass
from novelwriter.core import NWDoc
from novelwriter.gui.projtree import GuiProjectTree
from novelwriter.dialogs.docmerge import GuiDocMerge
from novelwriter.dialogs.docsplit import GuiDocSplit
@@ -714,7 +713,7 @@ def testGuiProjTree_MergeDocuments(qtbot, monkeypatch, nwGUI, fncDir, mockRnd, i
# The merge goes through
assert projTree._mergeDocuments(hChapter1, True) is True
assert len(NWDoc(theProject, mergedDoc1).readDocument()) > lenAll
assert len(theProject.storage.getDocument(mergedDoc1).readDocument()) > lenAll
# Merge to Existing Doc
# =====================
@@ -733,9 +732,9 @@ def testGuiProjTree_MergeDocuments(qtbot, monkeypatch, nwGUI, fncDir, mockRnd, i
# Successful merge, and move to trash
mergeData["moveToTrash"] = True
assert len(NWDoc(theProject, hChapter1).readDocument()) < lenAll
assert len(theProject.storage.getDocument(hChapter1).readDocument()) < lenAll
assert projTree._mergeDocuments(hChapter1, False) is True
assert len(NWDoc(theProject, hChapter1).readDocument()) > lenAll
assert len(theProject.storage.getDocument(hChapter1).readDocument()) > lenAll
assert theProject.tree.isTrash(hSceneOne11)
assert theProject.tree.isTrash(hSceneOne12)
+1 -2
View File
@@ -25,7 +25,6 @@ import pytest
from tools import C, buildTestProject
from novelwriter.enum import nwState
from novelwriter.core.document import NWDoc
@pytest.mark.gui
@@ -34,7 +33,7 @@ def testGuiStatusBar_Main(qtbot, nwGUI, fncProj, mockRnd):
"""
buildTestProject(nwGUI, fncProj)
cHandle = nwGUI.theProject.newFile("A Note", C.hCharRoot)
newDoc = NWDoc(nwGUI.theProject, cHandle)
newDoc = nwGUI.theProject.storage.getDocument(cHandle)
newDoc.writeDocument("# A Note\n\n")
nwGUI.projView.projTree.revealNewTreeItem(cHandle)
nwGUI.rebuildIndex(beQuiet=True)