From 4d5c1b24555f7b35be337eed5f29e11a22d53e14 Mon Sep 17 00:00:00 2001 From: Veronica Berglyd Olsen <1619840+vkbo@users.noreply.github.com> Date: Sun, 30 Oct 2022 17:14:28 +0100 Subject: [PATCH] Update split document tests --- tests/test_core/test_core_doctools.py | 7 +++++++ tests/test_gui/test_gui_projtree.py | 5 ++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/tests/test_core/test_core_doctools.py b/tests/test_core/test_core_doctools.py index bcff60ce..02d87866 100644 --- a/tests/test_core/test_core_doctools.py +++ b/tests/test_core/test_core_doctools.py @@ -162,6 +162,8 @@ def testCoreDocTools_DocSplitter(monkeypatch, mockGUI, fncDir, outDir, refDir, m docText = "\n\n".join(docData) docRaw = docText.splitlines() assert NWDoc(theProject, hSplitDoc).writeDocument(docText) is True + theProject.tree[hSplitDoc].setStatus(C.sFinished) + theProject.tree[hSplitDoc].setImport(C.iMain) docSplitter = DocSplitter(theProject, hSplitDoc) assert docSplitter._srcItem.isFileType() @@ -242,6 +244,11 @@ def testCoreDocTools_DocSplitter(monkeypatch, mockGUI, fncDir, outDir, refDir, m "000000000002e", # Scene Five is after Scene Four ] + # Check that status and importance has been preserved + for rHandle in resDocHandle: + assert theProject.tree[rHandle].itemStatus == C.sFinished + assert theProject.tree[rHandle].itemImport == C.iMain + # Check handling of improper initialisation docSplitter = DocSplitter(theProject, C.hInvalid) assert docSplitter._srcHandle is None diff --git a/tests/test_gui/test_gui_projtree.py b/tests/test_gui/test_gui_projtree.py index 02efbb9a..31228e1e 100644 --- a/tests/test_gui/test_gui_projtree.py +++ b/tests/test_gui/test_gui_projtree.py @@ -837,14 +837,17 @@ def testGuiProjTree_SplitDocument(qtbot, monkeypatch, nwGUI, fncDir, mockRnd, ip assert tHandle in theProject.tree assert os.path.isfile(os.path.join(prjDir, "content", f"{tHandle}.nwd")) - # Add to a folder + # Add to a folder and move source to trash splitData["intoFolder"] = True + splitData["moveToTrash"] = True assert projTree._splitDocument(hSplitDoc) is True assert "0000000000029" in theProject.tree # The folder for tHandle in trdSet: assert tHandle in theProject.tree assert os.path.isfile(os.path.join(prjDir, "content", f"{tHandle}.nwd")) + assert theProject.tree.isTrash(hSplitDoc) is True + # Cancelled by user with monkeypatch.context() as mp: mp.setattr(GuiDocSplit, "result", lambda *a: QDialog.Rejected)