Remove the old build tool
This commit is contained in:
@@ -43,13 +43,6 @@ VALID_MAP = {
|
|||||||
"hideZeros", "hideNegative", "groupByDay", "showIdleTime", "histMax",
|
"hideZeros", "hideNegative", "groupByDay", "showIdleTime", "histMax",
|
||||||
},
|
},
|
||||||
"GuiDocSplit": {"spLevel", "intoFolder", "docHierarchy"},
|
"GuiDocSplit": {"spLevel", "intoFolder", "docHierarchy"},
|
||||||
"GuiBuildNovel": {
|
|
||||||
"winWidth", "winHeight", "boxWidth", "docWidth", "hideScene",
|
|
||||||
"hideSection", "addNovel", "addNotes", "ignoreFlag", "justifyText",
|
|
||||||
"excludeBody", "textFont", "textSize", "lineHeight", "noStyling",
|
|
||||||
"incSynopsis", "incComments", "incKeywords", "incBodyText",
|
|
||||||
"replaceTabs", "replaceUCode", "rootFilter",
|
|
||||||
},
|
|
||||||
"GuiOutline": {"headerOrder", "columnWidth", "columnHidden"},
|
"GuiOutline": {"headerOrder", "columnWidth", "columnHidden"},
|
||||||
"GuiProjectSettings": {
|
"GuiProjectSettings": {
|
||||||
"winWidth", "winHeight", "replaceColW", "statusColW", "importColW",
|
"winWidth", "winHeight", "replaceColW", "statusColW", "importColW",
|
||||||
|
|||||||
@@ -829,11 +829,6 @@ class GuiMainMenu(QMenuBar):
|
|||||||
self.aBackupProject.triggered.connect(lambda: self.theProject.backupProject(True))
|
self.aBackupProject.triggered.connect(lambda: self.theProject.backupProject(True))
|
||||||
self.toolsMenu.addAction(self.aBackupProject)
|
self.toolsMenu.addAction(self.aBackupProject)
|
||||||
|
|
||||||
# Tools > Build Novel Project
|
|
||||||
self.aBuildProject = QAction(self.tr("Build Novel Project"), self)
|
|
||||||
self.aBuildProject.triggered.connect(self.mainGui.showBuildProjectDialog)
|
|
||||||
self.toolsMenu.addAction(self.aBuildProject)
|
|
||||||
|
|
||||||
# Tools > Build Manuscript
|
# Tools > Build Manuscript
|
||||||
self.aBuildManuscript = QAction(self.tr("Build Manuscript"), self)
|
self.aBuildManuscript = QAction(self.tr("Build Manuscript"), self)
|
||||||
self.aBuildManuscript.setShortcut("F5")
|
self.aBuildManuscript.setShortcut("F5")
|
||||||
|
|||||||
@@ -82,8 +82,8 @@ class GuiSideBar(QToolBar):
|
|||||||
|
|
||||||
self.aBuild = QAction(self.tr("Build"), self)
|
self.aBuild = QAction(self.tr("Build"), self)
|
||||||
self.aBuild.setFont(lblFont)
|
self.aBuild.setFont(lblFont)
|
||||||
self.aBuild.setToolTip(self.tr("Build Novel Project"))
|
self.aBuild.setToolTip(self.tr("Build Manuscript"))
|
||||||
self.aBuild.triggered.connect(lambda: self.mainGui.showBuildProjectDialog())
|
self.aBuild.triggered.connect(lambda: self.mainGui.showBuildManuscriptDialog())
|
||||||
|
|
||||||
self.aDetails = QAction(self.tr("Details"), self)
|
self.aDetails = QAction(self.tr("Details"), self)
|
||||||
self.aDetails.setFont(lblFont)
|
self.aDetails.setFont(lblFont)
|
||||||
|
|||||||
@@ -55,7 +55,6 @@ from novelwriter.dialogs.wordlist import GuiWordList
|
|||||||
from novelwriter.dialogs.preferences import GuiPreferences
|
from novelwriter.dialogs.preferences import GuiPreferences
|
||||||
from novelwriter.dialogs.projdetails import GuiProjectDetails
|
from novelwriter.dialogs.projdetails import GuiProjectDetails
|
||||||
from novelwriter.dialogs.projsettings import GuiProjectSettings
|
from novelwriter.dialogs.projsettings import GuiProjectSettings
|
||||||
from novelwriter.tools.build import GuiBuildNovel
|
|
||||||
from novelwriter.tools.lipsum import GuiLipsum
|
from novelwriter.tools.lipsum import GuiLipsum
|
||||||
from novelwriter.tools.manuscript import GuiManuscript
|
from novelwriter.tools.manuscript import GuiManuscript
|
||||||
from novelwriter.tools.projwizard import GuiProjectWizard
|
from novelwriter.tools.projwizard import GuiProjectWizard
|
||||||
@@ -1010,26 +1009,6 @@ class GuiMain(QMainWindow):
|
|||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def showBuildProjectDialog(self):
|
|
||||||
"""Open the build project dialog.
|
|
||||||
"""
|
|
||||||
if not self.hasProject:
|
|
||||||
logger.error("No project open")
|
|
||||||
return False
|
|
||||||
|
|
||||||
dlgBuild = getGuiItem("GuiBuildNovel")
|
|
||||||
if dlgBuild is None:
|
|
||||||
dlgBuild = GuiBuildNovel(self)
|
|
||||||
assert isinstance(dlgBuild, GuiBuildNovel)
|
|
||||||
|
|
||||||
dlgBuild.setModal(False)
|
|
||||||
dlgBuild.show()
|
|
||||||
dlgBuild.raise_()
|
|
||||||
qApp.processEvents()
|
|
||||||
dlgBuild.viewCachedDoc()
|
|
||||||
|
|
||||||
return True
|
|
||||||
|
|
||||||
@pyqtSlot()
|
@pyqtSlot()
|
||||||
def showBuildManuscriptDialog(self):
|
def showBuildManuscriptDialog(self):
|
||||||
"""Open the build manuscript dialog.
|
"""Open the build manuscript dialog.
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -32,8 +32,7 @@ from novelwriter.gui.noveltree import NovelTreeColumn
|
|||||||
|
|
||||||
@pytest.mark.core
|
@pytest.mark.core
|
||||||
def testCoreOptions_LoadSave(monkeypatch, mockGUI, fncPath):
|
def testCoreOptions_LoadSave(monkeypatch, mockGUI, fncPath):
|
||||||
"""Test loading and saving from the OptionState class.
|
"""Test loading and saving from the OptionState class."""
|
||||||
"""
|
|
||||||
theProject = NWProject(mockGUI)
|
theProject = NWProject(mockGUI)
|
||||||
theOpts = OptionState(theProject)
|
theOpts = OptionState(theProject)
|
||||||
|
|
||||||
@@ -43,13 +42,12 @@ def testCoreOptions_LoadSave(monkeypatch, mockGUI, fncPath):
|
|||||||
# Write a test file
|
# Write a test file
|
||||||
optFile = metaDir / nwFiles.OPTS_FILE
|
optFile = metaDir / nwFiles.OPTS_FILE
|
||||||
optFile.write_text(json.dumps({
|
optFile.write_text(json.dumps({
|
||||||
"GuiBuildNovel": {
|
"GuiProjectSettings": {
|
||||||
"winWidth": 1000,
|
"winWidth": 570,
|
||||||
"winHeight": 700,
|
"winHeight": 375,
|
||||||
"addNovel": True,
|
"replaceColW": 130,
|
||||||
"addNotes": False,
|
"statusColW": 130,
|
||||||
"textFont": "Cantarell",
|
"importColW": 130
|
||||||
"mockItem": None,
|
|
||||||
},
|
},
|
||||||
"MockGroup": {
|
"MockGroup": {
|
||||||
"mockItem": None,
|
"mockItem": None,
|
||||||
@@ -76,12 +74,12 @@ def testCoreOptions_LoadSave(monkeypatch, mockGUI, fncPath):
|
|||||||
|
|
||||||
# Check that unwanted items have been removed
|
# Check that unwanted items have been removed
|
||||||
assert theOpts._theState == {
|
assert theOpts._theState == {
|
||||||
"GuiBuildNovel": {
|
"GuiProjectSettings": {
|
||||||
"winWidth": 1000,
|
"winWidth": 570,
|
||||||
"winHeight": 700,
|
"winHeight": 375,
|
||||||
"addNovel": True,
|
"replaceColW": 130,
|
||||||
"addNotes": False,
|
"statusColW": 130,
|
||||||
"textFont": "Cantarell",
|
"importColW": 130
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -91,12 +89,12 @@ def testCoreOptions_LoadSave(monkeypatch, mockGUI, fncPath):
|
|||||||
# Load again to check we get the values back
|
# Load again to check we get the values back
|
||||||
assert theOpts.loadSettings()
|
assert theOpts.loadSettings()
|
||||||
assert theOpts._theState == {
|
assert theOpts._theState == {
|
||||||
"GuiBuildNovel": {
|
"GuiProjectSettings": {
|
||||||
"winWidth": 1000,
|
"winWidth": 570,
|
||||||
"winHeight": 700,
|
"winHeight": 375,
|
||||||
"addNovel": True,
|
"replaceColW": 130,
|
||||||
"addNotes": False,
|
"statusColW": 130,
|
||||||
"textFont": "Cantarell",
|
"importColW": 130
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -105,8 +103,7 @@ def testCoreOptions_LoadSave(monkeypatch, mockGUI, fncPath):
|
|||||||
|
|
||||||
@pytest.mark.core
|
@pytest.mark.core
|
||||||
def testCoreOptions_SetGet(mockGUI):
|
def testCoreOptions_SetGet(mockGUI):
|
||||||
"""Test setting and getting values from the OptionState class.
|
"""Test setting and getting values from the OptionState class."""
|
||||||
"""
|
|
||||||
theProject = NWProject(mockGUI)
|
theProject = NWProject(mockGUI)
|
||||||
theOpts = OptionState(theProject)
|
theOpts = OptionState(theProject)
|
||||||
|
|
||||||
@@ -114,36 +111,33 @@ def testCoreOptions_SetGet(mockGUI):
|
|||||||
|
|
||||||
# Set invalid values
|
# Set invalid values
|
||||||
assert theOpts.setValue("MockGroup", "mockItem", None) is False
|
assert theOpts.setValue("MockGroup", "mockItem", None) is False
|
||||||
assert theOpts.setValue("GuiBuildNovel", "mockItem", None) is False
|
assert theOpts.setValue("GuiProjectSettings", "mockItem", None) is False
|
||||||
|
|
||||||
# Set valid value
|
# Set valid value
|
||||||
assert theOpts.setValue("GuiBuildNovel", "winWidth", 100)
|
assert theOpts.setValue("GuiProjectSettings", "winWidth", 100) is True
|
||||||
|
|
||||||
# Set some values of different types
|
# Set some values of different types
|
||||||
assert theOpts.setValue("GuiBuildNovel", "winWidth", 100)
|
assert theOpts.setValue("GuiProjectDetails", "winWidth", 100) is True
|
||||||
assert theOpts.setValue("GuiBuildNovel", "winHeight", 12.34)
|
assert theOpts.setValue("GuiProjectDetails", "winHeight", 12.34) is True
|
||||||
assert theOpts.setValue("GuiBuildNovel", "addNovel", True)
|
assert theOpts.setValue("GuiProjectDetails", "clearDouble", True) is True
|
||||||
assert theOpts.setValue("GuiBuildNovel", "textFont", "Cantarell")
|
assert theOpts.setValue("GuiNovelView", "lastCol", nwColHidden) is True
|
||||||
assert theOpts.setValue("GuiNovelView", "lastCol", nwColHidden)
|
|
||||||
|
|
||||||
# Generic get, doesn't check type
|
# Generic get, doesn't check type
|
||||||
assert theOpts.getValue("GuiBuildNovel", "winWidth", None) == 100
|
assert theOpts.getValue("GuiProjectDetails", "winWidth", None) == 100
|
||||||
assert theOpts.getValue("GuiBuildNovel", "winHeight", None) == 12.34
|
assert theOpts.getValue("GuiProjectDetails", "winHeight", None) == 12.34
|
||||||
assert theOpts.getValue("GuiBuildNovel", "addNovel", None) is True
|
assert theOpts.getValue("GuiProjectDetails", "clearDouble", None) is True
|
||||||
assert theOpts.getValue("GuiBuildNovel", "textFont", None) == "Cantarell"
|
assert theOpts.getValue("GuiProjectDetails", "mockItem", None) is None
|
||||||
assert theOpts.getValue("GuiBuildNovel", "mockItem", None) is None
|
|
||||||
|
|
||||||
# Get type-specific
|
# Get type-specific
|
||||||
assert theOpts.getString("GuiBuildNovel", "winWidth", None) is None
|
assert theOpts.getString("GuiProjectDetails", "winWidth", None) is None
|
||||||
assert theOpts.getString("GuiBuildNovel", "mockItem", None) is None
|
assert theOpts.getString("GuiProjectDetails", "mockItem", None) is None
|
||||||
assert theOpts.getInt("GuiBuildNovel", "winWidth", None) == 100
|
assert theOpts.getInt("GuiProjectDetails", "winWidth", None) == 100
|
||||||
assert theOpts.getInt("GuiBuildNovel", "textFont", None) is None
|
assert theOpts.getInt("GuiProjectDetails", "textFont", None) is None
|
||||||
assert theOpts.getInt("GuiBuildNovel", "mockItem", None) is None
|
assert theOpts.getInt("GuiProjectDetails", "mockItem", None) is None
|
||||||
assert theOpts.getFloat("GuiBuildNovel", "winWidth", None) == 100.0
|
assert theOpts.getFloat("GuiProjectDetails", "winWidth", None) == 100.0
|
||||||
assert theOpts.getFloat("GuiBuildNovel", "textFont", None) is None
|
assert theOpts.getFloat("GuiProjectDetails", "mockItem", None) is None
|
||||||
assert theOpts.getFloat("GuiBuildNovel", "mockItem", None) is None
|
assert theOpts.getBool("GuiProjectDetails", "clearDouble", None) is True
|
||||||
assert theOpts.getBool("GuiBuildNovel", "addNovel", None) is True
|
assert theOpts.getBool("GuiProjectDetails", "mockItem", None) is None
|
||||||
assert theOpts.getBool("GuiBuildNovel", "mockItem", None) is None
|
|
||||||
assert theOpts.getEnum("GuiNovelView", "lastCol", NovelTreeColumn, None) == nwColHidden
|
assert theOpts.getEnum("GuiNovelView", "lastCol", NovelTreeColumn, None) == nwColHidden
|
||||||
|
|
||||||
# Get from non-existent groups
|
# Get from non-existent groups
|
||||||
|
|||||||
@@ -63,7 +63,7 @@ def testGuiMain_ProjectBlocker(nwGUI):
|
|||||||
assert nwGUI.rebuildIndex() is False
|
assert nwGUI.rebuildIndex() is False
|
||||||
assert nwGUI.showProjectSettingsDialog() is False
|
assert nwGUI.showProjectSettingsDialog() is False
|
||||||
assert nwGUI.showProjectDetailsDialog() is False
|
assert nwGUI.showProjectDetailsDialog() is False
|
||||||
assert nwGUI.showBuildProjectDialog() is False
|
assert nwGUI.showBuildManuscriptDialog() is False
|
||||||
assert nwGUI.showProjectWordListDialog() is False
|
assert nwGUI.showProjectWordListDialog() is False
|
||||||
assert nwGUI.showWritingStatsDialog() is False
|
assert nwGUI.showWritingStatsDialog() is False
|
||||||
|
|
||||||
|
|||||||
@@ -1,262 +0,0 @@
|
|||||||
"""
|
|
||||||
novelWriter – Build Dialog Class Tester
|
|
||||||
=======================================
|
|
||||||
|
|
||||||
This file is a part of novelWriter
|
|
||||||
Copyright 2018–2023, Veronica Berglyd Olsen
|
|
||||||
|
|
||||||
This program is free software: you can redistribute it and/or modify
|
|
||||||
it under the terms of the GNU General Public License as published by
|
|
||||||
the Free Software Foundation, either version 3 of the License, or
|
|
||||||
(at your option) any later version.
|
|
||||||
|
|
||||||
This program is distributed in the hope that it will be useful, but
|
|
||||||
WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
||||||
General Public License for more details.
|
|
||||||
|
|
||||||
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
|
|
||||||
|
|
||||||
from shutil import copyfile
|
|
||||||
|
|
||||||
from tools import ODT_IGNORE, cmpFiles, getGuiItem
|
|
||||||
|
|
||||||
from PyQt5.QtCore import Qt
|
|
||||||
from PyQt5.QtWidgets import QAction, QFileDialog
|
|
||||||
|
|
||||||
from novelwriter import CONFIG
|
|
||||||
from novelwriter.tools.build import GuiBuildNovel
|
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.gui
|
|
||||||
@pytest.mark.skip
|
|
||||||
def testToolBuild_Main(qtbot, monkeypatch, nwGUI, prjLipsum, tstPaths):
|
|
||||||
"""Test the build tool.
|
|
||||||
"""
|
|
||||||
# Block message box
|
|
||||||
monkeypatch.setattr(QFileDialog, "getSaveFileName", lambda a, b, c, **k: (c, None))
|
|
||||||
|
|
||||||
# Check that we cannot open when there is no project
|
|
||||||
nwGUI.mainMenu.aBuildProject.activate(QAction.Trigger)
|
|
||||||
assert getGuiItem("GuiBuildNovel") is None
|
|
||||||
|
|
||||||
# Open a project
|
|
||||||
assert nwGUI.openProject(prjLipsum)
|
|
||||||
|
|
||||||
# Open the tool
|
|
||||||
nwGUI.mainMenu.aBuildProject.activate(QAction.Trigger)
|
|
||||||
qtbot.waitUntil(lambda: getGuiItem("GuiBuildNovel") is not None, timeout=1000)
|
|
||||||
|
|
||||||
nwBuild = getGuiItem("GuiBuildNovel")
|
|
||||||
assert isinstance(nwBuild, GuiBuildNovel)
|
|
||||||
|
|
||||||
nwBuild.textFont.setText("DejaVu Sans")
|
|
||||||
nwBuild.textSize.setValue(11)
|
|
||||||
|
|
||||||
# Test Save
|
|
||||||
# =========
|
|
||||||
|
|
||||||
# Invalid file format
|
|
||||||
assert not nwBuild._saveDocument(-1)
|
|
||||||
|
|
||||||
# No path selected
|
|
||||||
with monkeypatch.context() as mp:
|
|
||||||
mp.setattr(QFileDialog, "getSaveFileName", lambda *a, **k: ("", ""))
|
|
||||||
assert not nwBuild._saveDocument(nwBuild.FMT_NWD)
|
|
||||||
|
|
||||||
# Default Settings
|
|
||||||
CONFIG._lastPath = prjLipsum
|
|
||||||
qtbot.mouseClick(nwBuild.buildNovel, Qt.LeftButton)
|
|
||||||
|
|
||||||
assert nwBuild._saveDocument(nwBuild.FMT_NWD)
|
|
||||||
projFile = prjLipsum / "Lorem Ipsum.nwd"
|
|
||||||
testFile = tstPaths.outDir / "guiBuild_Tool_Step1_Lorem_Ipsum.nwd"
|
|
||||||
compFile = tstPaths.refDir / "guiBuild_Tool_Step1_Lorem_Ipsum.nwd"
|
|
||||||
copyfile(projFile, testFile)
|
|
||||||
assert cmpFiles(testFile, compFile)
|
|
||||||
|
|
||||||
assert nwBuild._saveDocument(nwBuild.FMT_HTM)
|
|
||||||
projFile = prjLipsum / "Lorem Ipsum.htm"
|
|
||||||
testFile = tstPaths.outDir / "guiBuild_Tool_Step1_Lorem_Ipsum.htm"
|
|
||||||
compFile = tstPaths.refDir / "guiBuild_Tool_Step1_Lorem_Ipsum.htm"
|
|
||||||
copyfile(projFile, testFile)
|
|
||||||
assert cmpFiles(testFile, compFile)
|
|
||||||
|
|
||||||
assert nwBuild._saveDocument(nwBuild.FMT_MD)
|
|
||||||
projFile = prjLipsum / "Lorem Ipsum.md"
|
|
||||||
testFile = tstPaths.outDir / "guiBuild_Tool_Step1_Lorem_Ipsum.md"
|
|
||||||
compFile = tstPaths.refDir / "guiBuild_Tool_Step1_Lorem_Ipsum.md"
|
|
||||||
copyfile(projFile, testFile)
|
|
||||||
assert cmpFiles(testFile, compFile)
|
|
||||||
|
|
||||||
assert nwBuild._saveDocument(nwBuild.FMT_GH)
|
|
||||||
projFile = prjLipsum / "Lorem Ipsum.md"
|
|
||||||
testFile = tstPaths.outDir / "guiBuild_Tool_Step1G_Lorem_Ipsum.md"
|
|
||||||
compFile = tstPaths.refDir / "guiBuild_Tool_Step1G_Lorem_Ipsum.md"
|
|
||||||
copyfile(projFile, testFile)
|
|
||||||
assert cmpFiles(testFile, compFile)
|
|
||||||
|
|
||||||
assert nwBuild._saveDocument(nwBuild.FMT_FODT)
|
|
||||||
projFile = prjLipsum / "Lorem Ipsum.fodt"
|
|
||||||
testFile = tstPaths.outDir / "guiBuild_Tool_Step1_Lorem_Ipsum.fodt"
|
|
||||||
compFile = tstPaths.refDir / "guiBuild_Tool_Step1_Lorem_Ipsum.fodt"
|
|
||||||
copyfile(projFile, testFile)
|
|
||||||
assert cmpFiles(testFile, compFile, ignoreStart=ODT_IGNORE)
|
|
||||||
|
|
||||||
# Change Title Formats and Flip Switches
|
|
||||||
nwBuild.fmtChapter.setText(r"Chapter %chw%: %title%")
|
|
||||||
nwBuild.fmtScene.setText(r"Scene %ch%.%sc%: %title%")
|
|
||||||
nwBuild.fmtSection.setText(r"%ch%.%sc%.1: %title%")
|
|
||||||
|
|
||||||
qtbot.mouseClick(nwBuild.justifyText, Qt.LeftButton)
|
|
||||||
qtbot.mouseClick(nwBuild.includeSynopsis, Qt.LeftButton)
|
|
||||||
qtbot.mouseClick(nwBuild.includeComments, Qt.LeftButton)
|
|
||||||
qtbot.mouseClick(nwBuild.includeKeywords, Qt.LeftButton)
|
|
||||||
qtbot.mouseClick(nwBuild.replaceUCode, Qt.LeftButton)
|
|
||||||
|
|
||||||
qtbot.mouseClick(nwBuild.noteFiles, Qt.LeftButton)
|
|
||||||
qtbot.mouseClick(nwBuild.ignoreFlag, Qt.LeftButton)
|
|
||||||
|
|
||||||
qtbot.mouseClick(nwBuild.buildNovel, Qt.LeftButton)
|
|
||||||
|
|
||||||
assert nwBuild._saveDocument(nwBuild.FMT_NWD)
|
|
||||||
projFile = prjLipsum / "Lorem Ipsum.nwd"
|
|
||||||
testFile = tstPaths.outDir / "guiBuild_Tool_Step2_Lorem_Ipsum.nwd"
|
|
||||||
compFile = tstPaths.refDir / "guiBuild_Tool_Step2_Lorem_Ipsum.nwd"
|
|
||||||
copyfile(projFile, testFile)
|
|
||||||
assert cmpFiles(testFile, compFile)
|
|
||||||
|
|
||||||
assert nwBuild._saveDocument(nwBuild.FMT_HTM)
|
|
||||||
projFile = prjLipsum / "Lorem Ipsum.htm"
|
|
||||||
testFile = tstPaths.outDir / "guiBuild_Tool_Step2_Lorem_Ipsum.htm"
|
|
||||||
compFile = tstPaths.refDir / "guiBuild_Tool_Step2_Lorem_Ipsum.htm"
|
|
||||||
copyfile(projFile, testFile)
|
|
||||||
assert cmpFiles(testFile, compFile)
|
|
||||||
|
|
||||||
assert nwBuild._saveDocument(nwBuild.FMT_MD)
|
|
||||||
projFile = prjLipsum / "Lorem Ipsum.md"
|
|
||||||
testFile = tstPaths.outDir / "guiBuild_Tool_Step2_Lorem_Ipsum.md"
|
|
||||||
compFile = tstPaths.refDir / "guiBuild_Tool_Step2_Lorem_Ipsum.md"
|
|
||||||
copyfile(projFile, testFile)
|
|
||||||
assert cmpFiles(testFile, compFile)
|
|
||||||
|
|
||||||
assert nwBuild._saveDocument(nwBuild.FMT_FODT)
|
|
||||||
projFile = prjLipsum / "Lorem Ipsum.fodt"
|
|
||||||
testFile = tstPaths.outDir / "guiBuild_Tool_Step2_Lorem_Ipsum.fodt"
|
|
||||||
compFile = tstPaths.refDir / "guiBuild_Tool_Step2_Lorem_Ipsum.fodt"
|
|
||||||
copyfile(projFile, testFile)
|
|
||||||
assert cmpFiles(testFile, compFile, ignoreStart=ODT_IGNORE)
|
|
||||||
|
|
||||||
# Replace Tabs with Spaces
|
|
||||||
qtbot.mouseClick(nwBuild.replaceTabs, Qt.LeftButton)
|
|
||||||
|
|
||||||
qtbot.mouseClick(nwBuild.buildNovel, Qt.LeftButton)
|
|
||||||
|
|
||||||
# Save files that can be compared
|
|
||||||
assert nwBuild._saveDocument(nwBuild.FMT_NWD)
|
|
||||||
projFile = prjLipsum / "Lorem Ipsum.nwd"
|
|
||||||
testFile = tstPaths.outDir / "guiBuild_Tool_Step3_Lorem_Ipsum.nwd"
|
|
||||||
compFile = tstPaths.refDir / "guiBuild_Tool_Step3_Lorem_Ipsum.nwd"
|
|
||||||
copyfile(projFile, testFile)
|
|
||||||
assert cmpFiles(testFile, compFile)
|
|
||||||
|
|
||||||
assert nwBuild._saveDocument(nwBuild.FMT_HTM)
|
|
||||||
projFile = prjLipsum / "Lorem Ipsum.htm"
|
|
||||||
testFile = tstPaths.outDir / "guiBuild_Tool_Step3_Lorem_Ipsum.htm"
|
|
||||||
compFile = tstPaths.refDir / "guiBuild_Tool_Step3_Lorem_Ipsum.htm"
|
|
||||||
copyfile(projFile, testFile)
|
|
||||||
assert cmpFiles(testFile, compFile)
|
|
||||||
|
|
||||||
assert nwBuild._saveDocument(nwBuild.FMT_MD)
|
|
||||||
projFile = prjLipsum / "Lorem Ipsum.md"
|
|
||||||
testFile = tstPaths.outDir / "guiBuild_Tool_Step3_Lorem_Ipsum.md"
|
|
||||||
compFile = tstPaths.refDir / "guiBuild_Tool_Step3_Lorem_Ipsum.md"
|
|
||||||
copyfile(projFile, testFile)
|
|
||||||
assert cmpFiles(testFile, compFile)
|
|
||||||
|
|
||||||
assert nwBuild._saveDocument(nwBuild.FMT_FODT)
|
|
||||||
projFile = prjLipsum / "Lorem Ipsum.fodt"
|
|
||||||
testFile = tstPaths.outDir / "guiBuild_Tool_Step3_Lorem_Ipsum.fodt"
|
|
||||||
compFile = tstPaths.refDir / "guiBuild_Tool_Step3_Lorem_Ipsum.fodt"
|
|
||||||
copyfile(projFile, testFile)
|
|
||||||
assert cmpFiles(testFile, compFile, ignoreStart=ODT_IGNORE)
|
|
||||||
|
|
||||||
# Putline Mode
|
|
||||||
nwBuild.fmtChapter.setText(r"Chapter %chw%: %title%")
|
|
||||||
nwBuild.fmtScene.setText(r"Scene %sca%: %title%")
|
|
||||||
nwBuild.fmtSection.setText(r"Section: %title%")
|
|
||||||
|
|
||||||
qtbot.mouseClick(nwBuild.includeComments, Qt.LeftButton)
|
|
||||||
qtbot.mouseClick(nwBuild.noteFiles, Qt.LeftButton)
|
|
||||||
qtbot.mouseClick(nwBuild.ignoreFlag, Qt.LeftButton)
|
|
||||||
qtbot.mouseClick(nwBuild.includeBody, Qt.LeftButton)
|
|
||||||
|
|
||||||
qtbot.mouseClick(nwBuild.buildNovel, Qt.LeftButton)
|
|
||||||
|
|
||||||
# Save files that can be compared
|
|
||||||
assert nwBuild._saveDocument(nwBuild.FMT_NWD)
|
|
||||||
projFile = prjLipsum / "Lorem Ipsum.nwd"
|
|
||||||
testFile = tstPaths.outDir / "guiBuild_Tool_Step4_Lorem_Ipsum.nwd"
|
|
||||||
compFile = tstPaths.refDir / "guiBuild_Tool_Step4_Lorem_Ipsum.nwd"
|
|
||||||
copyfile(projFile, testFile)
|
|
||||||
assert cmpFiles(testFile, compFile)
|
|
||||||
|
|
||||||
assert nwBuild._saveDocument(nwBuild.FMT_HTM)
|
|
||||||
projFile = prjLipsum / "Lorem Ipsum.htm"
|
|
||||||
testFile = tstPaths.outDir / "guiBuild_Tool_Step4_Lorem_Ipsum.htm"
|
|
||||||
compFile = tstPaths.refDir / "guiBuild_Tool_Step4_Lorem_Ipsum.htm"
|
|
||||||
copyfile(projFile, testFile)
|
|
||||||
assert cmpFiles(testFile, compFile)
|
|
||||||
|
|
||||||
# Check the JSON files too at this stage
|
|
||||||
assert nwBuild._saveDocument(nwBuild.FMT_JSON_H)
|
|
||||||
projFile = prjLipsum / "Lorem Ipsum.json"
|
|
||||||
testFile = tstPaths.outDir / "guiBuild_Tool_Step4H_Lorem_Ipsum.json"
|
|
||||||
compFile = tstPaths.refDir / "guiBuild_Tool_Step4H_Lorem_Ipsum.json"
|
|
||||||
copyfile(projFile, testFile)
|
|
||||||
assert cmpFiles(testFile, compFile, [6])
|
|
||||||
|
|
||||||
assert nwBuild._saveDocument(nwBuild.FMT_JSON_M)
|
|
||||||
projFile = prjLipsum / "Lorem Ipsum.json"
|
|
||||||
testFile = tstPaths.outDir / "guiBuild_Tool_Step4M_Lorem_Ipsum.json"
|
|
||||||
compFile = tstPaths.refDir / "guiBuild_Tool_Step4M_Lorem_Ipsum.json"
|
|
||||||
copyfile(projFile, testFile)
|
|
||||||
assert cmpFiles(testFile, compFile, [6])
|
|
||||||
|
|
||||||
# Since odt and fodt is built by the same code, we don't check the
|
|
||||||
# output. but just that the different format can be written as well
|
|
||||||
assert nwBuild._saveDocument(nwBuild.FMT_ODT)
|
|
||||||
assert (prjLipsum / "Lorem Ipsum.odt").is_file()
|
|
||||||
|
|
||||||
# Print to PDF
|
|
||||||
if not CONFIG.osDarwin:
|
|
||||||
assert nwBuild._saveDocument(nwBuild.FMT_PDF)
|
|
||||||
assert (prjLipsum / "Lorem Ipsum.pdf").is_file()
|
|
||||||
|
|
||||||
# Close the build tool
|
|
||||||
htmlText = nwBuild.htmlText
|
|
||||||
htmlStyle = nwBuild.htmlStyle
|
|
||||||
buildTime = nwBuild.buildTime
|
|
||||||
nwBuild._doClose()
|
|
||||||
|
|
||||||
# Re-open build dialog from cahce
|
|
||||||
nwGUI.mainMenu.aBuildProject.activate(QAction.Trigger)
|
|
||||||
qtbot.waitUntil(lambda: getGuiItem("GuiBuildNovel") is not None, timeout=1000)
|
|
||||||
|
|
||||||
nwBuild = getGuiItem("GuiBuildNovel")
|
|
||||||
assert isinstance(nwBuild, GuiBuildNovel)
|
|
||||||
|
|
||||||
assert nwBuild.viewCachedDoc()
|
|
||||||
assert nwBuild.htmlText == htmlText
|
|
||||||
assert nwBuild.htmlStyle == htmlStyle
|
|
||||||
assert nwBuild.buildTime == buildTime
|
|
||||||
|
|
||||||
nwBuild._doClose()
|
|
||||||
|
|
||||||
# qtbot.stop()
|
|
||||||
|
|
||||||
# END Test testToolBuild_Main
|
|
||||||
Reference in New Issue
Block a user