Extended build tool test
This commit is contained in:
+2
-2
@@ -468,7 +468,7 @@ class GuiBuildNovel(QDialog):
|
||||
self.buildProgress.setMaximum(len(self.theProject.projTree))
|
||||
self.buildProgress.setValue(0)
|
||||
|
||||
tStart = time()
|
||||
tStart = int(time())
|
||||
|
||||
self.htmlText = []
|
||||
self.htmlStyle = []
|
||||
@@ -511,7 +511,7 @@ class GuiBuildNovel(QDialog):
|
||||
# Update progress bar, also for skipped items
|
||||
self.buildProgress.setValue(nItt+1)
|
||||
|
||||
tEnd = time()
|
||||
tEnd = int(time())
|
||||
logger.debug("Built project in %.3f ms" % (1000*(tEnd-tStart)))
|
||||
self.htmlStyle = makeHtml.getStyleSheet()
|
||||
self.buildTime = tEnd
|
||||
|
||||
@@ -0,0 +1,71 @@
|
||||
{
|
||||
"meta": {
|
||||
"workingTitle": "Lorem Ipsum",
|
||||
"novelTitle": "Lorem Ipsum",
|
||||
"authors": [
|
||||
"lipsum.com"
|
||||
],
|
||||
"buildTime": 1601120680
|
||||
},
|
||||
"text": {
|
||||
"css": [
|
||||
"p {text-align: justify;}",
|
||||
"h1, h2 {color: rgb(66, 113, 174);}",
|
||||
"h3, h4 {color: rgb(50, 50, 50);}",
|
||||
"h1, h2, h3, h4 {page-break-after: avoid;}",
|
||||
"a {color: rgb(66, 113, 174);}",
|
||||
".title {font-size: 2.5em;}",
|
||||
".tags {color: rgb(245, 135, 31); font-weight: bold;}",
|
||||
".break {text-align: left;}",
|
||||
".sep {text-align: center; margin-top: 1em; margin-bottom: 1em;}",
|
||||
".skip {margin-top: 1em; margin-bottom: 1em;}",
|
||||
".synopsis {font-style: italic;}",
|
||||
".comment {font-style: italic; color: rgb(100, 100, 100);}"
|
||||
],
|
||||
"html": [
|
||||
[
|
||||
"<h1 class='title' style='text-align: center; page-break-before: never;'>Lorem Ipsum</h1>"
|
||||
],
|
||||
[
|
||||
""
|
||||
],
|
||||
[
|
||||
"<h1 style='page-break-before: always;'>Prologue</h1>",
|
||||
"<p class='synopsis'><strong>Synopsis: </strong>Explanation from the lipsum.com website.</p>"
|
||||
],
|
||||
[
|
||||
"<h1 style='text-align: center; page-break-before: always;'>Act One</h1>"
|
||||
],
|
||||
[
|
||||
"<h1 style='page-break-before: always;'>Chapter One: Chapter One</h1>",
|
||||
"<div><span class='tags'>Point of View:</span> <a href='#tag_Bod'>Bod</a></div><div><span class='tags'>Plot:</span> <a href='#tag_Main'>Main</a></div><div><span class='tags'>Locations:</span> <a href='#tag_Europe'>Europe</a></div><p class='synopsis'><strong>Synopsis: </strong>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque at aliquam quam.</p>"
|
||||
],
|
||||
[
|
||||
"<h2>Scene 1: Scene One</h2>",
|
||||
"<div><span class='tags'>Point of View:</span> <a href='#tag_Bod'>Bod</a></div><div><span class='tags'>Plot:</span> <a href='#tag_Main'>Main</a></div><div><span class='tags'>Locations:</span> <a href='#tag_Europe'>Europe</a></div><p class='synopsis'><strong>Synopsis: </strong>Aenean ut placerat velit. Etiam laoreet ullamcorper risus, eget lobortis enim scelerisque non. Suspendisse id maximus nunc, et mollis sapien. Curabitur vel semper sapien, non pulvinar dolor. Etiam finibus nisi vel mi molestie consectetur.</p>",
|
||||
"<h3>Section: Scene One, Section Two</h3>"
|
||||
],
|
||||
[
|
||||
"<h2>Scene 2: Scene Two</h2>",
|
||||
"<div><span class='tags'>Point of View:</span> <a href='#tag_Bod'>Bod</a></div><div><span class='tags'>Plot:</span> <a href='#tag_Main'>Main</a></div><div><span class='tags'>Locations:</span> <a href='#tag_Europe'>Europe</a></div><p class='synopsis'><strong>Synopsis: </strong>Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Integer sapien nulla, dictum at lacus a, dignissim consectetur dolor. Nunc vel eleifend lacus, eu dapibus orci.</p>",
|
||||
"<h3>Section: Scene Two, Section Two</h3>"
|
||||
],
|
||||
[
|
||||
"<h1 style='page-break-before: always;'>Chapter Two: Chapter Two</h1>",
|
||||
"<div><span class='tags'>Point of View:</span> <a href='#tag_Bod'>Bod</a></div><div><span class='tags'>Plot:</span> <a href='#tag_Main'>Main</a></div><div><span class='tags'>Locations:</span> <a href='#tag_Europe'>Europe</a></div><p class='synopsis'><strong>Synopsis: </strong>Curabitur a elit posuere, varius ex et, convallis neque. Phasellus sagittis pharetra sem vitae dapibus. Curabitur varius lorem non pulvinar congue.</p>"
|
||||
],
|
||||
[
|
||||
"<h2>Scene 3: Scene Three</h2>",
|
||||
"<div><span class='tags'>Point of View:</span> <a href='#tag_Bod'>Bod</a></div><div><span class='tags'>Plot:</span> <a href='#tag_Main'>Main</a></div><div><span class='tags'>Locations:</span> <a href='#tag_Europe'>Europe</a></div><p class='synopsis'><strong>Synopsis: </strong>Aenean ut libero ut lectus porttitor rhoncus vel et massa. Nam pretium, nibh et varius vehicula, urna metus blandit eros, euismod pharetra diam diam et libero. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos.</p>"
|
||||
],
|
||||
[
|
||||
"<h2>Scene 4: Scene Four</h2>",
|
||||
"<div><span class='tags'>Point of View:</span> <a href='#tag_Bod'>Bod</a></div><div><span class='tags'>Plot:</span> <a href='#tag_Main'>Main</a></div><div><span class='tags'>Locations:</span> <a href='#tag_Europe'>Europe</a></div><p class='synopsis'><strong>Synopsis: </strong>Nam tempor blandit magna laoreet aliquet. Vestibulum auctor posuere leo, ac gravida nisi rhoncus varius. Aenean posuere dolor vitae condimentum volutpat. Donec egestas volutpat risus, quis luctus justo.</p>"
|
||||
],
|
||||
[
|
||||
"<h2>Scene 5: Scene Five</h2>",
|
||||
"<div><span class='tags'>Point of View:</span> <a href='#tag_Bod'>Bod</a></div><div><span class='tags'>Plot:</span> <a href='#tag_Main'>Main</a></div><div><span class='tags'>Locations:</span> <a href='#tag_Europe'>Europe</a></div><p class='synopsis'><strong>Synopsis: </strong>Praesent eget est porta, dictum ante in, egestas risus. Mauris risus mauris, consequat aliquam mauris et, feugiat iaculis ipsum. Aliquam arcu ipsum, fermentum ut arcu sed, lobortis euismod sem. Orci varius natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus.</p>"
|
||||
]
|
||||
]
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,150 @@
|
||||
{
|
||||
"meta": {
|
||||
"workingTitle": "Lorem Ipsum",
|
||||
"novelTitle": "Lorem Ipsum",
|
||||
"authors": [
|
||||
"lipsum.com"
|
||||
],
|
||||
"buildTime": 1601120788
|
||||
},
|
||||
"text": {
|
||||
"nwd": [
|
||||
[
|
||||
"# Lorem Ipsum",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
""
|
||||
],
|
||||
[
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
""
|
||||
],
|
||||
[
|
||||
"## Prologue",
|
||||
"",
|
||||
"% Synopsis:Explanation from the lipsum.com website.",
|
||||
"",
|
||||
"",
|
||||
""
|
||||
],
|
||||
[
|
||||
"# Act One",
|
||||
"",
|
||||
"",
|
||||
""
|
||||
],
|
||||
[
|
||||
"## Chapter One",
|
||||
"",
|
||||
"@pov: Bod",
|
||||
"@plot: Main",
|
||||
"@location: Europe",
|
||||
"",
|
||||
"% Synopsis: Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque at aliquam quam.",
|
||||
"",
|
||||
"",
|
||||
""
|
||||
],
|
||||
[
|
||||
"### Scene One",
|
||||
"",
|
||||
"@pov: Bod",
|
||||
"@plot: Main",
|
||||
"@location: Europe",
|
||||
"",
|
||||
"% Synopsis: Aenean ut placerat velit. Etiam laoreet ullamcorper risus, eget lobortis enim scelerisque non. Suspendisse id maximus nunc, et mollis sapien. Curabitur vel semper sapien, non pulvinar dolor. Etiam finibus nisi vel mi molestie consectetur.",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"#### Scene One, Section Two",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
""
|
||||
],
|
||||
[
|
||||
"### Scene Two",
|
||||
"",
|
||||
"@pov: Bod",
|
||||
"@plot: Main",
|
||||
"@location: Europe",
|
||||
"",
|
||||
"% Synopsis: Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Integer sapien nulla, dictum at lacus a, dignissim consectetur dolor. Nunc vel eleifend lacus, eu dapibus orci. ",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"#### Scene Two, Section Two",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
""
|
||||
],
|
||||
[
|
||||
"## Chapter Two",
|
||||
"",
|
||||
"@pov: Bod",
|
||||
"@plot: Main",
|
||||
"@location: Europe",
|
||||
"",
|
||||
"% Synopsis: Curabitur a elit posuere, varius ex et, convallis neque. Phasellus sagittis pharetra sem vitae dapibus. Curabitur varius lorem non pulvinar congue.",
|
||||
"",
|
||||
"",
|
||||
""
|
||||
],
|
||||
[
|
||||
"### Scene Three",
|
||||
"",
|
||||
"@pov: Bod",
|
||||
"@plot: Main",
|
||||
"@location: Europe",
|
||||
"",
|
||||
"% Synopsis: Aenean ut libero ut lectus porttitor rhoncus vel et massa. Nam pretium, nibh et varius vehicula, urna metus blandit eros, euismod pharetra diam diam et libero. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos.",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
""
|
||||
],
|
||||
[
|
||||
"### Scene Four",
|
||||
"",
|
||||
"@pov: Bod",
|
||||
"@plot: Main",
|
||||
"@location: Europe",
|
||||
"",
|
||||
"% Synopsis: Nam tempor blandit magna laoreet aliquet. Vestibulum auctor posuere leo, ac gravida nisi rhoncus varius. Aenean posuere dolor vitae condimentum volutpat. Donec egestas volutpat risus, quis luctus justo.",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
""
|
||||
],
|
||||
[
|
||||
"### Scene Five",
|
||||
"",
|
||||
"@pov: Bod",
|
||||
"@plot: Main",
|
||||
"@location: Europe",
|
||||
"",
|
||||
"% Synopsis: Praesent eget est porta, dictum ante in, egestas risus. Mauris risus mauris, consequat aliquam mauris et, feugiat iaculis ipsum. Aliquam arcu ipsum, fermentum ut arcu sed, lobortis euismod sem. Orci varius natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus.",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
""
|
||||
]
|
||||
]
|
||||
}
|
||||
}
|
||||
+46
-3
@@ -440,23 +440,66 @@ def testBuildTool(qtbot, nwTempBuild, nwLipsum, nwRef, nwTemp):
|
||||
|
||||
qtbot.mouseClick(nwBuild.buildNovel, Qt.LeftButton)
|
||||
|
||||
# Save files that can be compared
|
||||
assert nwBuild._saveDocument(nwBuild.FMT_NWD)
|
||||
assert nwBuild._saveDocument(nwBuild.FMT_HTM)
|
||||
|
||||
projFile = path.join(nwLipsum, "Lorem Ipsum.nwd")
|
||||
testFile = path.join(nwTempBuild, "3_LoremIpsum.nwd")
|
||||
refFile = path.join(nwRef, "build", "3_LoremIpsum.nwd")
|
||||
copyfile(projFile, testFile)
|
||||
assert cmpFiles(testFile, refFile)
|
||||
|
||||
assert nwBuild._saveDocument(nwBuild.FMT_HTM)
|
||||
projFile = path.join(nwLipsum, "Lorem Ipsum.htm")
|
||||
testFile = path.join(nwTempBuild, "3_LoremIpsum.htm")
|
||||
refFile = path.join(nwRef, "build", "3_LoremIpsum.htm")
|
||||
copyfile(projFile, testFile)
|
||||
assert cmpFiles(testFile, refFile)
|
||||
|
||||
# qtbot.stopForInteraction()
|
||||
# Check the JSON files too at this stage
|
||||
assert nwBuild._saveDocument(nwBuild.FMT_JSON_H)
|
||||
projFile = path.join(nwLipsum, "Lorem Ipsum.json")
|
||||
testFile = path.join(nwTempBuild, "3H_LoremIpsum.json")
|
||||
refFile = path.join(nwRef, "build", "3H_LoremIpsum.json")
|
||||
copyfile(projFile, testFile)
|
||||
assert cmpFiles(testFile, refFile, [8])
|
||||
|
||||
assert nwBuild._saveDocument(nwBuild.FMT_JSON_M)
|
||||
projFile = path.join(nwLipsum, "Lorem Ipsum.json")
|
||||
testFile = path.join(nwTempBuild, "3M_LoremIpsum.json")
|
||||
refFile = path.join(nwRef, "build", "3M_LoremIpsum.json")
|
||||
copyfile(projFile, testFile)
|
||||
assert cmpFiles(testFile, refFile, [8])
|
||||
|
||||
# Save other file types handled by Qt
|
||||
# We assume the export itself by the Qt library works, so we just
|
||||
# check that novelWriter successfully writes the files.
|
||||
assert nwBuild._saveDocument(nwBuild.FMT_ODT)
|
||||
assert nwBuild._saveDocument(nwBuild.FMT_PDF)
|
||||
assert nwBuild._saveDocument(nwBuild.FMT_MD)
|
||||
assert nwBuild._saveDocument(nwBuild.FMT_TXT)
|
||||
assert path.isfile(path.join(nwLipsum, "Lorem Ipsum.odt"))
|
||||
assert path.isfile(path.join(nwLipsum, "Lorem Ipsum.pdf"))
|
||||
assert path.isfile(path.join(nwLipsum, "Lorem Ipsum.md"))
|
||||
assert path.isfile(path.join(nwLipsum, "Lorem Ipsum.txt"))
|
||||
|
||||
# Close the build tool
|
||||
htmlText = nwBuild.htmlText
|
||||
htmlStyle = nwBuild.htmlStyle
|
||||
nwdText = nwBuild.nwdText
|
||||
buildTime = nwBuild.buildTime
|
||||
nwBuild._doClose()
|
||||
|
||||
# Re-open build dialog from cahce
|
||||
nwBuild = GuiBuildNovel(nwGUI, nwGUI.theProject)
|
||||
|
||||
assert nwBuild.htmlText == htmlText
|
||||
assert nwBuild.htmlStyle == htmlStyle
|
||||
assert nwBuild.nwdText == nwdText
|
||||
assert nwBuild.buildTime == buildTime
|
||||
|
||||
nwBuild._doClose()
|
||||
|
||||
# qtbot.stopForInteraction()
|
||||
nwGUI.closeMain()
|
||||
|
||||
@pytest.mark.gui
|
||||
|
||||
Reference in New Issue
Block a user