Update tests
This commit is contained in:
@@ -1,13 +1,13 @@
|
||||
<?xml version='1.0' encoding='utf-8'?>
|
||||
<office:document xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:fo="urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0" xmlns:loext="urn:org:documentfoundation:names:experimental:office:xmlns:loext:1.0" xmlns:meta="urn:oasis:names:tc:opendocument:xmlns:meta:1.0" xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0" xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0" xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0" office:version="1.3" office:mimetype="application/vnd.oasis.opendocument.text">
|
||||
<office:meta>
|
||||
<meta:creation-date>2024-04-27T16:43:44</meta:creation-date>
|
||||
<meta:generator>novelWriter/2.5a2</meta:generator>
|
||||
<meta:creation-date>2024-05-10T15:23:56</meta:creation-date>
|
||||
<meta:generator>novelWriter/2.5a3</meta:generator>
|
||||
<meta:initial-creator>lipsum.com</meta:initial-creator>
|
||||
<meta:editing-cycles>45</meta:editing-cycles>
|
||||
<meta:editing-duration>P0DT0H36M8S</meta:editing-duration>
|
||||
<dc:title>Lorem Ipsum</dc:title>
|
||||
<dc:date>2024-04-27T16:43:44</dc:date>
|
||||
<dc:date>2024-05-10T15:23:56</dc:date>
|
||||
<dc:creator>lipsum.com</dc:creator>
|
||||
</office:meta>
|
||||
<office:font-face-decls>
|
||||
@@ -121,7 +121,7 @@
|
||||
<text:p text:style-name="P1">“Neque porro quisquam est qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit…”</text:p>
|
||||
<text:p text:style-name="P1">“There is no one who loves pain itself, who seeks after it and wants to have it, simply because it is pain…”</text:p>
|
||||
<text:p text:style-name="P2"><text:span text:style-name="T1">Comment:</text:span> Exctracted from the lipsum.com website.</text:p>
|
||||
<text:p text:style-name="Text_20_body">Contrary to popular belief, Lorem Ipsum is not simply random text. It has roots in a piece of classical Latin literature from 45 BC, making it over 2000 years old. Richard McClintock, a Latin professor at Hampden-Sydney College in Virginia, looked up one of the more obscure Latin words, consectetur, from a Lorem Ipsum passage, and going through the cites of the word in classical literature, discovered the undoubtable source. Lorem Ipsum comes from sections 1.10.32 and 1.10.33 of “de Finibus Bonorum et Malorum” (The Extremes of Good and Evil) by Cicero, written in 45 BC. This book is a treatise on the theory of ethics, very popular during the Renaissance. The first line of Lorem Ipsum, “Lorem ipsum dolor sit amet..”, comes from a line in section 1.10.32.</text:p>
|
||||
<text:p text:style-name="First_20_line_20_indent">Contrary to popular belief, Lorem Ipsum is not simply random text. It has roots in a piece of classical Latin literature from 45 BC, making it over 2000 years old. Richard McClintock, a Latin professor at Hampden-Sydney College in Virginia, looked up one of the more obscure Latin words, consectetur, from a Lorem Ipsum passage, and going through the cites of the word in classical literature, discovered the undoubtable source. Lorem Ipsum comes from sections 1.10.32 and 1.10.33 of “de Finibus Bonorum et Malorum” (The Extremes of Good and Evil) by Cicero, written in 45 BC. This book is a treatise on the theory of ethics, very popular during the Renaissance. The first line of Lorem Ipsum, “Lorem ipsum dolor sit amet..”, comes from a line in section 1.10.32.</text:p>
|
||||
<text:p text:style-name="First_20_line_20_indent">The standard chunk of Lorem Ipsum used since the 1500s is reproduced below for those interested. Sections 1.10.32 and 1.10.33 from “de Finibus Bonorum et Malorum” by Cicero are also reproduced in their exact original form, accompanied by English versions from the 1914 translation by H. Rackham.</text:p>
|
||||
<text:h text:style-name="P3" text:outline-level="2">Prologue</text:h>
|
||||
<text:p text:style-name="Text_20_Meta"><text:span text:style-name="T1">Synopsis:</text:span> Explanation from the lipsum.com website.</text:p>
|
||||
|
||||
@@ -21,21 +21,22 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
from __future__ import annotations
|
||||
|
||||
import json
|
||||
|
||||
from pathlib import Path
|
||||
from shutil import copyfile
|
||||
|
||||
import pytest
|
||||
|
||||
from shutil import copyfile
|
||||
from pathlib import Path
|
||||
|
||||
from tools import C, ODT_IGNORE, buildTestProject, cmpFiles
|
||||
from mocked import causeException, causeOSError
|
||||
|
||||
from novelwriter.enum import nwBuildFmt
|
||||
from novelwriter.core.buildsettings import BuildSettings
|
||||
from novelwriter.core.docbuild import NWBuildDocument
|
||||
from novelwriter.core.project import NWProject
|
||||
from novelwriter.core.tohtml import ToHtml
|
||||
from novelwriter.core.tomd import ToMarkdown
|
||||
from novelwriter.core.toodt import ToOdt
|
||||
from novelwriter.core.tohtml import ToHtml
|
||||
from novelwriter.core.project import NWProject
|
||||
from novelwriter.core.docbuild import NWBuildDocument
|
||||
from novelwriter.core.buildsettings import BuildSettings
|
||||
from novelwriter.enum import nwBuildFmt
|
||||
|
||||
from tests.mocked import causeException, causeOSError
|
||||
from tests.tools import ODT_IGNORE, C, buildTestProject, cmpFiles
|
||||
|
||||
BUILD_CONF = {
|
||||
"name": "Test Build",
|
||||
@@ -63,8 +64,8 @@ BUILD_CONF = {
|
||||
"format.justifyText": True,
|
||||
"format.stripUnicode": False,
|
||||
"format.replaceTabs": True,
|
||||
"format.firstLineIndent": True,
|
||||
"odt.addColours": True,
|
||||
"odt.firstLineIndent": True,
|
||||
"html.addStyles": True,
|
||||
},
|
||||
"content": {
|
||||
|
||||
@@ -753,8 +753,10 @@ def testCoreToOdt_SaveFlat(mockGUI, fncPath, tstPaths):
|
||||
assert odt._colourHead is True
|
||||
odt.setHeaderFormat(nwHeadFmt.ODT_AUTO, 1)
|
||||
assert odt._headerFormat == nwHeadFmt.ODT_AUTO
|
||||
odt.setFirstLineIndent(True)
|
||||
odt.setFirstLineIndent(True, 1.4, False)
|
||||
assert odt._firstIndent is True
|
||||
assert odt._fTextIndent == "0.499cm"
|
||||
assert odt._indentFirst is False
|
||||
|
||||
odt.setPageLayout(148, 210, 20, 18, 17, 15)
|
||||
assert odt._mDocWidth == "14.800cm"
|
||||
|
||||
@@ -22,27 +22,24 @@ from __future__ import annotations
|
||||
|
||||
import pytest
|
||||
|
||||
from pathlib import Path
|
||||
from pytestqt.qtbot import QtBot
|
||||
|
||||
from tools import C, buildTestProject
|
||||
|
||||
from PyQt5.QtGui import QFont
|
||||
from PyQt5.QtCore import pyqtSlot
|
||||
from PyQt5.QtGui import QFont
|
||||
from PyQt5.QtWidgets import QFontDialog
|
||||
|
||||
from novelwriter import CONFIG, SHARED
|
||||
from novelwriter.guimain import GuiMain
|
||||
from novelwriter.constants import nwHeadFmt
|
||||
from novelwriter.core.buildsettings import BuildSettings, FilterMode
|
||||
from novelwriter.tools.manussettings import (
|
||||
GuiBuildSettings, _OutputTab, _FormatTab, _ContentTab, _HeadingsTab, _FilterTab
|
||||
GuiBuildSettings, _ContentTab, _FilterTab, _FormatTab, _HeadingsTab,
|
||||
_OutputTab
|
||||
)
|
||||
from novelwriter.types import QtDialogApply, QtDialogClose, QtDialogSave
|
||||
|
||||
from tests.tools import C, buildTestProject
|
||||
|
||||
|
||||
@pytest.mark.gui
|
||||
def testBuildSettings_Init(qtbot: QtBot, nwGUI: GuiMain, projPath: Path, mockRnd):
|
||||
def testBuildSettings_Init(qtbot, nwGUI, projPath, mockRnd):
|
||||
"""Test the initialisation of the GuiBuildSettings dialog."""
|
||||
buildTestProject(nwGUI, projPath)
|
||||
nwGUI.openProject(projPath)
|
||||
@@ -114,7 +111,7 @@ def testBuildSettings_Init(qtbot: QtBot, nwGUI: GuiMain, projPath: Path, mockRnd
|
||||
|
||||
|
||||
@pytest.mark.gui
|
||||
def testBuildSettings_Filter(qtbot: QtBot, nwGUI: GuiMain, projPath: Path, mockRnd):
|
||||
def testBuildSettings_Filter(qtbot, nwGUI, projPath, mockRnd):
|
||||
"""Test the Filter Tab of the GuiBuildSettings dialog."""
|
||||
buildTestProject(nwGUI, projPath)
|
||||
nwGUI.openProject(projPath)
|
||||
@@ -320,7 +317,7 @@ def testBuildSettings_Filter(qtbot: QtBot, nwGUI: GuiMain, projPath: Path, mockR
|
||||
|
||||
|
||||
@pytest.mark.gui
|
||||
def testBuildSettings_Headings(qtbot: QtBot, nwGUI: GuiMain):
|
||||
def testBuildSettings_Headings(qtbot, nwGUI):
|
||||
"""Test the Headings Tab of the GuiBuildSettings dialog."""
|
||||
build = BuildSettings()
|
||||
|
||||
@@ -492,7 +489,7 @@ def testBuildSettings_Headings(qtbot: QtBot, nwGUI: GuiMain):
|
||||
|
||||
|
||||
@pytest.mark.gui
|
||||
def testBuildSettings_Content(qtbot: QtBot, nwGUI: GuiMain):
|
||||
def testBuildSettings_Content(qtbot, nwGUI):
|
||||
"""Test the Content Tab of the GuiBuildSettings dialog."""
|
||||
build = BuildSettings()
|
||||
|
||||
@@ -554,7 +551,7 @@ def testBuildSettings_Content(qtbot: QtBot, nwGUI: GuiMain):
|
||||
|
||||
|
||||
@pytest.mark.gui
|
||||
def testBuildSettings_Format(monkeypatch, qtbot: QtBot, nwGUI: GuiMain):
|
||||
def testBuildSettings_Format(monkeypatch, qtbot, nwGUI):
|
||||
"""Test the Format Tab of the GuiBuildSettings dialog."""
|
||||
build = BuildSettings()
|
||||
|
||||
@@ -596,6 +593,10 @@ def testBuildSettings_Format(monkeypatch, qtbot: QtBot, nwGUI: GuiMain):
|
||||
assert fmtTab.stripUnicode.isChecked() is False
|
||||
assert fmtTab.replaceTabs.isChecked() is False
|
||||
|
||||
assert fmtTab.firstIndent.isChecked() is False
|
||||
assert fmtTab.indentWidth.value() == 1.4
|
||||
assert fmtTab.indentFirstPar.isChecked() is False
|
||||
|
||||
assert fmtTab.pageUnit.currentData() == "mm"
|
||||
assert fmtTab.pageSize.currentData() == "Custom"
|
||||
assert fmtTab.pageWidth.value() == 180.0
|
||||
@@ -614,6 +615,10 @@ def testBuildSettings_Format(monkeypatch, qtbot: QtBot, nwGUI: GuiMain):
|
||||
fmtTab.stripUnicode.setChecked(True)
|
||||
fmtTab.replaceTabs.setChecked(True)
|
||||
|
||||
fmtTab.firstIndent.setChecked(True)
|
||||
fmtTab.indentWidth.setValue(2.0)
|
||||
fmtTab.indentFirstPar.setChecked(True)
|
||||
|
||||
fmtTab.pageUnit.setCurrentIndex(fmtTab.pageUnit.findData("cm"))
|
||||
fmtTab.pageSize.setCurrentIndex(fmtTab.pageSize.findData("A4"))
|
||||
|
||||
@@ -628,6 +633,10 @@ def testBuildSettings_Format(monkeypatch, qtbot: QtBot, nwGUI: GuiMain):
|
||||
assert build.getBool("format.stripUnicode") is True
|
||||
assert build.getBool("format.replaceTabs") is True
|
||||
|
||||
assert build.getBool("format.firstLineIndent") is True
|
||||
assert build.getFloat("format.firstIndentWidth") == 2.0
|
||||
assert build.getBool("format.indentFirstPar") is True
|
||||
|
||||
assert fmtTab.pageUnit.currentData() == "cm"
|
||||
assert fmtTab.pageSize.currentData() == "A4"
|
||||
assert fmtTab.pageWidth.value() == 21.0
|
||||
@@ -656,7 +665,7 @@ def testBuildSettings_Format(monkeypatch, qtbot: QtBot, nwGUI: GuiMain):
|
||||
|
||||
|
||||
@pytest.mark.gui
|
||||
def testBuildSettings_Output(qtbot: QtBot, nwGUI: GuiMain):
|
||||
def testBuildSettings_Output(qtbot, nwGUI):
|
||||
"""Test the Output Tab of the GuiBuildSettings dialog."""
|
||||
build = BuildSettings()
|
||||
|
||||
@@ -676,14 +685,12 @@ def testBuildSettings_Output(qtbot: QtBot, nwGUI: GuiMain):
|
||||
assert outTab.odtAddColours.isChecked() is False
|
||||
assert outTab.odtPageHeader.text() == nwHeadFmt.ODT_AUTO
|
||||
assert outTab.odtPageCountOffset.value() == 0
|
||||
assert outTab.odtFirstLineIndent.isChecked() is False
|
||||
assert outTab.htmlAddStyles.isChecked() is False
|
||||
assert outTab.htmlPreserveTabs.isChecked() is False
|
||||
assert outTab.mdPreserveBreaks.isChecked() is True
|
||||
|
||||
# Toggle all
|
||||
outTab.odtAddColours.setChecked(True)
|
||||
outTab.odtFirstLineIndent.setChecked(True)
|
||||
outTab.htmlAddStyles.setChecked(True)
|
||||
outTab.htmlPreserveTabs.setChecked(True)
|
||||
outTab.mdPreserveBreaks.setChecked(False)
|
||||
@@ -698,7 +705,6 @@ def testBuildSettings_Output(qtbot: QtBot, nwGUI: GuiMain):
|
||||
assert build.getBool("odt.addColours") is True
|
||||
assert build.getStr("odt.pageHeader") == "Stuff"
|
||||
assert build.getInt("odt.pageCountOffset") == 1
|
||||
assert build.getBool("odt.firstLineIndent") is True
|
||||
assert build.getBool("html.addStyles") is True
|
||||
assert build.getBool("html.preserveTabs") is True
|
||||
assert build.getBool("md.preserveBreaks") is False
|
||||
|
||||
Reference in New Issue
Block a user