From 5ab1402854d94b034c92ff2713f5cf6aba0d1c25 Mon Sep 17 00:00:00 2001 From: "Veronica K. B. Olsen" <1619840+vkbo@users.noreply.github.com> Date: Sun, 10 May 2020 16:12:47 +0200 Subject: [PATCH] Fix tests --- nw/core/project.py | 2 +- sample/sampleNovel/nwProject.nwx | 11 ++++++++++- tests/reference/gui/0_nwProject.nwx | 17 ++++++++++++++++- tests/reference/gui/1_nwProject.nwx | 20 +++++++++++++++++++- tests/reference/gui/2_nwProject.nwx | 17 ++++++++++++++++- tests/reference/gui/3_nwProject.nwx | 17 ++++++++++++++++- tests/reference/proj/1_nwProject.nwx | 17 ++++++++++++++++- tests/reference/proj/2_nwProject.nwx | 21 ++++++++++++++++++++- tests/test_gui.py | 6 +++--- tests/test_item.py | 3 ++- 10 files changed, 119 insertions(+), 12 deletions(-) diff --git a/nw/core/project.py b/nw/core/project.py index c2ce2902..8986aeb3 100644 --- a/nw/core/project.py +++ b/nw/core/project.py @@ -358,7 +358,7 @@ class NWProject(): elif xItem.tag == "titleFormat": titleFormat = self.titleFormat.copy() for xEntry in xItem: - titleFormat[xEntry.tag] = checkString(xEntry.text, None, False) + titleFormat[xEntry.tag] = checkString(xEntry.text, "", False) self.setTitleFormat(titleFormat) elif xChild.tag == "content": logger.debug("Found project content") diff --git a/sample/sampleNovel/nwProject.nwx b/sample/sampleNovel/nwProject.nwx index 68ac9522..c911b0a3 100644 --- a/sample/sampleNovel/nwProject.nwx +++ b/sample/sampleNovel/nwProject.nwx @@ -1,5 +1,5 @@ - + Sample Project Sample Project @@ -18,6 +18,15 @@ E D + + %title% + Chapter %num% + %title% + %title% + None + * * * +
None
+
New Notes diff --git a/tests/reference/gui/0_nwProject.nwx b/tests/reference/gui/0_nwProject.nwx index e5368533..d91e4c30 100644 --- a/tests/reference/gui/0_nwProject.nwx +++ b/tests/reference/gui/0_nwProject.nwx @@ -1,5 +1,5 @@ - + @@ -12,6 +12,15 @@ None 0 + + %title% + Chapter %num% + %title% + %title% + + * * * +
+
New Note @@ -32,6 +41,7 @@ NOVEL New False + True New Chapter @@ -39,6 +49,7 @@ NOVEL New False + True New Scene @@ -46,6 +57,7 @@ NOVEL New False + True SCENE 0 0 @@ -58,6 +70,7 @@ CHARACTER New False + True Plot @@ -65,6 +78,7 @@ PLOT New False + True World @@ -72,6 +86,7 @@ WORLD New False + True
diff --git a/tests/reference/gui/1_nwProject.nwx b/tests/reference/gui/1_nwProject.nwx index c55ff681..0cb958d1 100644 --- a/tests/reference/gui/1_nwProject.nwx +++ b/tests/reference/gui/1_nwProject.nwx @@ -1,5 +1,5 @@ - + @@ -12,6 +12,15 @@ 31489056e0916 86 + + %title% + Chapter %num% + %title% + %title% + + * * * +
+
New Note @@ -32,6 +41,7 @@ NOVEL New True + True New Chapter @@ -39,6 +49,7 @@ NOVEL New True + True New Scene @@ -46,6 +57,7 @@ NOVEL New False + True SCENE 331 59 @@ -58,6 +70,7 @@ CHARACTER New True + True New File @@ -65,6 +78,7 @@ CHARACTER New False + True NOTE 34 8 @@ -77,6 +91,7 @@ PLOT New True + True New File @@ -84,6 +99,7 @@ PLOT New False + True NOTE 48 10 @@ -96,6 +112,7 @@ WORLD New True + True New File @@ -103,6 +120,7 @@ WORLD New False + True NOTE 51 9 diff --git a/tests/reference/gui/2_nwProject.nwx b/tests/reference/gui/2_nwProject.nwx index ca896ec2..0ab86944 100644 --- a/tests/reference/gui/2_nwProject.nwx +++ b/tests/reference/gui/2_nwProject.nwx @@ -1,5 +1,5 @@ - + Project Name Project Title @@ -16,6 +16,15 @@ With This Stuff + + %title% + Chapter %num% + %title% + %title% + + * * * +
+
New Note @@ -36,6 +45,7 @@ NOVEL New False + True
New Chapter @@ -43,6 +53,7 @@ NOVEL New False + True New Scene @@ -50,6 +61,7 @@ NOVEL New False + True SCENE 0 0 @@ -62,6 +74,7 @@ CHARACTER New False + True Plot @@ -69,6 +82,7 @@ PLOT New False + True World @@ -76,6 +90,7 @@ WORLD New False + True
diff --git a/tests/reference/gui/3_nwProject.nwx b/tests/reference/gui/3_nwProject.nwx index f0bda720..3d80a294 100644 --- a/tests/reference/gui/3_nwProject.nwx +++ b/tests/reference/gui/3_nwProject.nwx @@ -1,5 +1,5 @@ - + @@ -12,6 +12,15 @@ None 0 + + %title% + Chapter %num% + %title% + %title% + + * * * +
+
New Note @@ -32,6 +41,7 @@ NOVEL New False + True New Chapter @@ -39,6 +49,7 @@ NOVEL New False + True Just a Page @@ -46,6 +57,7 @@ NOVEL Note False + True PAGE 0 0 @@ -58,6 +70,7 @@ CHARACTER New False + True Plot @@ -65,6 +78,7 @@ PLOT New False + True World @@ -72,6 +86,7 @@ WORLD New False + True
diff --git a/tests/reference/proj/1_nwProject.nwx b/tests/reference/proj/1_nwProject.nwx index 319d24b3..76bfb4ae 100644 --- a/tests/reference/proj/1_nwProject.nwx +++ b/tests/reference/proj/1_nwProject.nwx @@ -1,5 +1,5 @@ - + @@ -12,6 +12,15 @@ None 0 + + %title% + Chapter %num% + %title% + %title% + + * * * +
+
New Note @@ -32,6 +41,7 @@ NOVEL New False + True Characters @@ -39,6 +49,7 @@ CHARACTER New False + True Plot @@ -46,6 +57,7 @@ PLOT New False + True World @@ -53,6 +65,7 @@ WORLD New False + True New Chapter @@ -60,6 +73,7 @@ NOVEL New False + True New Scene @@ -67,6 +81,7 @@ NOVEL New False + True SCENE 0 0 diff --git a/tests/reference/proj/2_nwProject.nwx b/tests/reference/proj/2_nwProject.nwx index 92bd9df4..585e7fb3 100644 --- a/tests/reference/proj/2_nwProject.nwx +++ b/tests/reference/proj/2_nwProject.nwx @@ -1,5 +1,5 @@ - + @@ -12,6 +12,15 @@ None 0 + + %title% + Chapter %num% + %title% + %title% + + * * * +
+
New Note @@ -32,6 +41,7 @@ NOVEL New False + True
Characters @@ -39,6 +49,7 @@ CHARACTER New False + True Plot @@ -46,6 +57,7 @@ PLOT New False + True World @@ -53,6 +65,7 @@ WORLD New False + True New Chapter @@ -60,6 +73,7 @@ NOVEL New False + True New Scene @@ -67,6 +81,7 @@ NOVEL New False + True SCENE 0 0 @@ -79,6 +94,7 @@ TIMELINE New False + True Object @@ -86,6 +102,7 @@ OBJECT New False + True Custom1 @@ -93,6 +110,7 @@ CUSTOM New False + True Custom2 @@ -100,6 +118,7 @@ CUSTOM New False + True
diff --git a/tests/test_gui.py b/tests/test_gui.py index e2291fff..9e2cd53d 100644 --- a/tests/test_gui.py +++ b/tests/test_gui.py @@ -13,7 +13,7 @@ from nw.gui.dialogs.itemeditor import GuiItemEditor from nw.constants import * -keyDelay = 10 +keyDelay = 5 stepDelay = 50 @pytest.mark.gui @@ -361,7 +361,7 @@ def testItemEditor(qtbot, nwTempGUI, nwRef, nwTemp): layoutIdx = itemEdit.editLayout.findData(nwItemLayout.PAGE) itemEdit.editLayout.setCurrentIndex(layoutIdx) - qtbot.mouseClick(itemEdit.saveButton, Qt.LeftButton) + itemEdit._doSave() itemEdit = GuiItemEditor(nwGUI, nwGUI.theProject, "31489056e0916") qtbot.addWidget(itemEdit) @@ -369,7 +369,7 @@ def testItemEditor(qtbot, nwTempGUI, nwRef, nwTemp): assert itemEdit.editStatus.currentData() == "Note" assert itemEdit.editLayout.currentData() == nwItemLayout.PAGE - qtbot.mouseClick(itemEdit.closeButton, Qt.LeftButton) + itemEdit._doClose() qtbot.wait(stepDelay) assert nwGUI.saveProject() diff --git a/tests/test_item.py b/tests/test_item.py index 64268e62..19f663f6 100644 --- a/tests/test_item.py +++ b/tests/test_item.py @@ -197,7 +197,8 @@ def testItemXMLPackUnpack(): assert etree.tostring(xContent, pretty_print=False, encoding="utf-8") == ( b"" b"" - b"A NameTRASHTRASHMainTrue" + b"A NameTRASHTRASHMain" + b"TrueTrue" b"" b"" )