Update tests
This commit is contained in:
@@ -19,22 +19,22 @@ 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 GuiDocSplit, GuiItemEditor
|
||||
from novelwriter.enum import nwItemType, nwWidget
|
||||
from novelwriter.core.document import NWDoc
|
||||
from novelwriter.dialogs import GuiDocSplit, GuiItemEditor
|
||||
from novelwriter.core.tree import NWTree
|
||||
from novelwriter.core.document import NWDoc
|
||||
|
||||
|
||||
@pytest.mark.gui
|
||||
def testDlgSplit_Main(qtbot, monkeypatch, nwGUI, fncProj):
|
||||
def testDlgSplit_Main(qtbot, monkeypatch, nwGUI, fncProj, mockRnd):
|
||||
"""Test the split document tool.
|
||||
"""
|
||||
# Block message box
|
||||
@@ -42,20 +42,20 @@ def testDlgSplit_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}) is True
|
||||
|
||||
# Handles for new objects
|
||||
hNovelRoot = "73475cb40a568"
|
||||
hChapterDir = "31489056e0916"
|
||||
hToSplit = "1a6562590ef19"
|
||||
hPartition = "41cfc0d1f2d12"
|
||||
hChapterOne = "2858dcd1057d3"
|
||||
hSceneOne = "2fca346db6561"
|
||||
hSceneTwo = "02d20bbd7e394"
|
||||
hSceneThree = "7688b6ef52555"
|
||||
hSceneFour = "c837649cce43f"
|
||||
hSceneFive = "6208ef0f7750c"
|
||||
hNovelRoot = "0000000000008"
|
||||
hChapterDir = "000000000000d"
|
||||
hToSplit = "0000000000010"
|
||||
hNewFolder = "0000000000021"
|
||||
hPartition = "0000000000022"
|
||||
hChapterOne = "0000000000023"
|
||||
hSceneOne = "0000000000024"
|
||||
hSceneTwo = "0000000000025"
|
||||
hSceneThree = "0000000000026"
|
||||
hSceneFour = "0000000000027"
|
||||
hSceneFive = "0000000000028"
|
||||
|
||||
# Add Project Content
|
||||
monkeypatch.setattr(GuiItemEditor, "exec_", lambda *a: QDialog.Accepted)
|
||||
@@ -173,52 +173,52 @@ def testDlgSplit_Main(qtbot, monkeypatch, nwGUI, fncProj):
|
||||
|
||||
assert readFile(os.path.join(contentDir, hPartition+".nwd")) == (
|
||||
"%%%%~name: Nantucket\n"
|
||||
"%%%%~path: 031b4af5197ec/%s\n"
|
||||
"%%%%~path: %s/%s\n"
|
||||
"%%%%~kind: NOVEL/DOCUMENT\n"
|
||||
"%s\n\n"
|
||||
) % (hPartition, tPartition)
|
||||
) % (hNewFolder, hPartition, tPartition)
|
||||
|
||||
assert readFile(os.path.join(contentDir, hChapterOne+".nwd")) == (
|
||||
"%%%%~name: Chapter One\n"
|
||||
"%%%%~path: 031b4af5197ec/%s\n"
|
||||
"%%%%~path: %s/%s\n"
|
||||
"%%%%~kind: NOVEL/DOCUMENT\n"
|
||||
"%s\n\n"
|
||||
) % (hChapterOne, tChapterOne)
|
||||
) % (hNewFolder, hChapterOne, tChapterOne)
|
||||
|
||||
assert readFile(os.path.join(contentDir, hSceneOne+".nwd")) == (
|
||||
"%%%%~name: Scene One\n"
|
||||
"%%%%~path: 031b4af5197ec/%s\n"
|
||||
"%%%%~path: %s/%s\n"
|
||||
"%%%%~kind: NOVEL/DOCUMENT\n"
|
||||
"%s\n\n"
|
||||
) % (hSceneOne, tSceneOne)
|
||||
) % (hNewFolder, hSceneOne, tSceneOne)
|
||||
|
||||
assert readFile(os.path.join(contentDir, hSceneTwo+".nwd")) == (
|
||||
"%%%%~name: Scene Two\n"
|
||||
"%%%%~path: 031b4af5197ec/%s\n"
|
||||
"%%%%~path: %s/%s\n"
|
||||
"%%%%~kind: NOVEL/DOCUMENT\n"
|
||||
"%s\n\n"
|
||||
) % (hSceneTwo, tSceneTwo)
|
||||
) % (hNewFolder, hSceneTwo, tSceneTwo)
|
||||
|
||||
assert readFile(os.path.join(contentDir, hSceneThree+".nwd")) == (
|
||||
"%%%%~name: Scene Three\n"
|
||||
"%%%%~path: 031b4af5197ec/%s\n"
|
||||
"%%%%~path: %s/%s\n"
|
||||
"%%%%~kind: NOVEL/DOCUMENT\n"
|
||||
"%s\n\n"
|
||||
) % (hSceneThree, tSceneThree)
|
||||
) % (hNewFolder, hSceneThree, tSceneThree)
|
||||
|
||||
assert readFile(os.path.join(contentDir, hSceneFour+".nwd")) == (
|
||||
"%%%%~name: Scene Four\n"
|
||||
"%%%%~path: 031b4af5197ec/%s\n"
|
||||
"%%%%~path: %s/%s\n"
|
||||
"%%%%~kind: NOVEL/DOCUMENT\n"
|
||||
"%s\n\n"
|
||||
) % (hSceneFour, tSceneFour)
|
||||
) % (hNewFolder, hSceneFour, tSceneFour)
|
||||
|
||||
assert readFile(os.path.join(contentDir, hSceneFive+".nwd")) == (
|
||||
"%%%%~name: The End\n"
|
||||
"%%%%~path: 031b4af5197ec/%s\n"
|
||||
"%%%%~path: %s/%s\n"
|
||||
"%%%%~kind: NOVEL/DOCUMENT\n"
|
||||
"%s\n\n"
|
||||
) % (hSceneFive, tSceneFive)
|
||||
) % (hNewFolder, hSceneFive, tSceneFive)
|
||||
|
||||
# OS error
|
||||
with monkeypatch.context() as mp:
|
||||
|
||||
Reference in New Issue
Block a user