From 91222f631f9ea34cd30f7c2050cc9d1b628c1593 Mon Sep 17 00:00:00 2001 From: Veronica Berglyd Olsen <1619840+vkbo@users.noreply.github.com> Date: Sat, 25 May 2024 23:02:34 +0200 Subject: [PATCH] Update manuscript tests --- tests/test_tools/test_tools_manusbuild.py | 2 +- tests/test_tools/test_tools_manuscript.py | 37 +++++++------------- tests/test_tools/test_tools_manussettings.py | 12 +++---- 3 files changed, 20 insertions(+), 31 deletions(-) diff --git a/tests/test_tools/test_tools_manusbuild.py b/tests/test_tools/test_tools_manusbuild.py index a1ca1175..eb1685aa 100644 --- a/tests/test_tools/test_tools_manusbuild.py +++ b/tests/test_tools/test_tools_manusbuild.py @@ -40,7 +40,7 @@ from tests.tools import buildTestProject @pytest.mark.gui -def testManuscriptBuild_Main( +def testToolManuscriptBuild_Main( monkeypatch, qtbot: QtBot, nwGUI: GuiMain, fncPath: Path, projPath: Path, mockRnd ): """Test the GuiManuscriptBuild dialog.""" diff --git a/tests/test_tools/test_tools_manuscript.py b/tests/test_tools/test_tools_manuscript.py index 383ff098..145fbfe5 100644 --- a/tests/test_tools/test_tools_manuscript.py +++ b/tests/test_tools/test_tools_manuscript.py @@ -40,7 +40,7 @@ from tests.tools import C, buildTestProject @pytest.mark.gui -def testManuscript_Init(monkeypatch, qtbot, nwGUI, projPath, mockRnd): +def testToolManuscript_Init(monkeypatch, qtbot, nwGUI, projPath, mockRnd): """Test the init/main functionality of the GuiManuscript dialog.""" buildTestProject(nwGUI, projPath) nwGUI.openProject(projPath) @@ -54,38 +54,27 @@ def testManuscript_Init(monkeypatch, qtbot, nwGUI, projPath, mockRnd): manus.show() assert manus.docPreview.toPlainText().strip() == "" - # Run the default build + # First load should have create a default build + assert manus.buildList.count() == 1 + + # Loading again should not add a new build + manus.loadContent() + assert manus.buildList.count() == 1 + + # Build a preview manus.buildList.clearSelection() manus.buildList.setCurrentRow(0) with qtbot.waitSignal(manus.docPreview.document().contentsChanged): manus.btnPreview.click() assert manus.docPreview.toPlainText().strip() == allText - manus.close() - - # # A new dialog should load the old build - # manus = GuiManuscript(nwGUI) - # manus.show() - # manus.loadContent() - # assert manus.docPreview.toPlainText().strip() == allText - # manus.close() - - # # But blocking the reload should leave it empty - # with monkeypatch.context() as mp: - # mp.setattr("builtins.open", lambda *a, **k: causeOSError) - # manus = GuiManuscript(nwGUI) - # manus.show() - # manus.loadContent() - # assert manus.docPreview.toPlainText().strip() == "" - - # nwGUI.closeProject() # This should auto-close the manuscript tool - # assert manus.isHidden() + nwGUI.closeProject() # This should auto-close the manuscript tool # qtbot.stop() @pytest.mark.gui -def testManuscript_Builds(qtbot, nwGUI, projPath): +def testToolManuscript_Builds(qtbot, nwGUI, projPath): """Test the handling of builds in the GuiManuscript dialog.""" buildTestProject(nwGUI, projPath) nwGUI.openProject(projPath) @@ -156,7 +145,7 @@ def testManuscript_Builds(qtbot, nwGUI, projPath): @pytest.mark.gui -def testManuscript_Features(monkeypatch, qtbot, nwGUI, projPath, mockRnd): +def testToolManuscript_Features(monkeypatch, qtbot, nwGUI, projPath, mockRnd): """Test other features of the GuiManuscript dialog.""" buildTestProject(nwGUI, projPath) nwGUI.openProject(projPath) @@ -280,7 +269,7 @@ def testManuscript_Features(monkeypatch, qtbot, nwGUI, projPath, mockRnd): @pytest.mark.gui @pytest.mark.skipif(sys.platform.startswith("darwin"), reason="Not running on Darwin") -def testManuscript_Print(monkeypatch, qtbot, nwGUI, projPath): +def testToolManuscript_Print(monkeypatch, qtbot, nwGUI, projPath): """Test the print feature of the GuiManuscript dialog.""" buildTestProject(nwGUI, projPath) nwGUI.openProject(projPath) diff --git a/tests/test_tools/test_tools_manussettings.py b/tests/test_tools/test_tools_manussettings.py index 7d8dd2f3..76a41a48 100644 --- a/tests/test_tools/test_tools_manussettings.py +++ b/tests/test_tools/test_tools_manussettings.py @@ -40,7 +40,7 @@ from tests.tools import C, buildTestProject @pytest.mark.gui -def testBuildSettings_Init(qtbot, nwGUI, projPath, mockRnd): +def testToolBuildSettings_Init(qtbot, nwGUI, projPath, mockRnd): """Test the initialisation of the GuiBuildSettings dialog.""" buildTestProject(nwGUI, projPath) nwGUI.openProject(projPath) @@ -110,7 +110,7 @@ def testBuildSettings_Init(qtbot, nwGUI, projPath, mockRnd): @pytest.mark.gui -def testBuildSettings_Filter(qtbot, nwGUI, projPath, mockRnd): +def testToolBuildSettings_Filter(qtbot, nwGUI, projPath, mockRnd): """Test the Filter Tab of the GuiBuildSettings dialog.""" buildTestProject(nwGUI, projPath) nwGUI.openProject(projPath) @@ -314,7 +314,7 @@ def testBuildSettings_Filter(qtbot, nwGUI, projPath, mockRnd): @pytest.mark.gui -def testBuildSettings_Headings(qtbot, nwGUI): +def testToolBuildSettings_Headings(qtbot, nwGUI): """Test the Headings Tab of the GuiBuildSettings dialog.""" build = BuildSettings() @@ -484,7 +484,7 @@ def testBuildSettings_Headings(qtbot, nwGUI): @pytest.mark.gui -def testBuildSettings_Content(qtbot, nwGUI): +def testToolBuildSettings_Content(qtbot, nwGUI): """Test the Content Tab of the GuiBuildSettings dialog.""" build = BuildSettings() @@ -544,7 +544,7 @@ def testBuildSettings_Content(qtbot, nwGUI): @pytest.mark.gui -def testBuildSettings_Format(monkeypatch, qtbot, nwGUI): +def testToolBuildSettings_Format(monkeypatch, qtbot, nwGUI): """Test the Format Tab of the GuiBuildSettings dialog.""" build = BuildSettings() @@ -650,7 +650,7 @@ def testBuildSettings_Format(monkeypatch, qtbot, nwGUI): @pytest.mark.gui -def testBuildSettings_Output(qtbot, nwGUI): +def testToolBuildSettings_Output(qtbot, nwGUI): """Test the Output Tab of the GuiBuildSettings dialog.""" build = BuildSettings()