Update tests

This commit is contained in:
Veronica Berglyd Olsen
2022-04-20 21:50:07 +02:00
parent e32eb21fbf
commit 607f9409d2
30 changed files with 740 additions and 781 deletions
+15 -13
View File
@@ -19,21 +19,21 @@ You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
"""
import pytest
import os
import pytest
from tools import getGuiItem, readFile, writeFile
from mock import causeOSError
from tools import getGuiItem, readFile, writeFile
from PyQt5.QtWidgets import QAction, QMessageBox, QDialog
from novelwriter.dialogs import GuiDocMerge, GuiItemEditor
from novelwriter.enum import nwItemType, nwWidget
from novelwriter.dialogs import GuiDocMerge, GuiItemEditor
from novelwriter.core.tree import NWTree
@pytest.mark.gui
def testDlgMerge_Main(qtbot, monkeypatch, nwGUI, fncProj):
def testDlgMerge_Main(qtbot, monkeypatch, nwGUI, fncProj, mockRnd):
"""Test the merge documents tool.
"""
# Block message box
@@ -41,17 +41,17 @@ def testDlgMerge_Main(qtbot, monkeypatch, nwGUI, fncProj):
monkeypatch.setattr(QMessageBox, "critical", lambda *a: QMessageBox.Ok)
# Create a new project
nwGUI.theProject.projTree.setSeed(42)
assert nwGUI.newProject({"projPath": fncProj})
# Handles for new objects
hChapterDir = "31489056e0916"
hChapterOne = "98010bd9270f9"
hSceneOne = "0e17daca5f3e1"
hSceneTwo = "1a6562590ef19"
hSceneThree = "031b4af5197ec"
hSceneFour = "41cfc0d1f2d12"
hMergedDoc = "2858dcd1057d3"
hNovelRoot = "0000000000008"
hChapterDir = "000000000000d"
hChapterOne = "000000000000e"
hSceneOne = "000000000000f"
hSceneTwo = "0000000000010"
hSceneThree = "0000000000011"
hSceneFour = "0000000000012"
hMergedDoc = "0000000000023"
# Add Project Content
monkeypatch.setattr(GuiItemEditor, "exec_", lambda *a: QDialog.Accepted)
@@ -137,7 +137,7 @@ def testDlgMerge_Main(qtbot, monkeypatch, nwGUI, fncProj):
assert os.path.isfile(mergedFile)
assert readFile(mergedFile) == (
"%%%%~name: New Chapter\n"
"%%%%~path: 73475cb40a568/2858dcd1057d3\n"
"%%%%~path: %s/%s\n"
"%%%%~kind: NOVEL/DOCUMENT\n"
"%s\n\n"
"%s\n\n"
@@ -145,6 +145,8 @@ def testDlgMerge_Main(qtbot, monkeypatch, nwGUI, fncProj):
"%s\n\n"
"%s\n\n"
) % (
hNovelRoot,
hMergedDoc,
tChapterOne.strip(),
tSceneOne.strip(),
tSceneTwo.strip(),