Updated tests

This commit is contained in:
Veronica K. B. Olsen
2020-10-24 18:56:01 +02:00
parent a9b264227a
commit 538009eff6
37 changed files with 120 additions and 67 deletions
+3 -3
View File
@@ -230,10 +230,10 @@ class NWDoc():
%%~ that may contain meta data.
"""
if metaLine.startswith("%%~name:"):
self._docMeta["name"] = metaLine[9:].strip()
self._docMeta["name"] = metaLine[8:].strip()
elif metaLine.startswith("%%~path:"):
metaVal = metaLine[9:].strip()
metaVal = metaLine[8:].strip()
metaBits = metaVal.split("/")
if len(metaBits) == 2:
if isHandle(metaBits[0]):
@@ -242,7 +242,7 @@ class NWDoc():
self._docMeta["handle"] = metaBits[1]
elif metaLine.startswith("%%~kind:"):
metaVal = metaLine[9:].strip()
metaVal = metaLine[8:].strip()
metaBits = metaVal.split("/")
if len(metaBits) == 2:
if metaBits[0] in nwItemClass.__members__:
+4 -1
View File
@@ -1,4 +1,7 @@
%%~ 636b6aa9b697b:e7ded148d6e4a:7031beac91f75:NOVEL:SCENE:Making a Scene
%%~name: Making a Scene
%%~path: e7ded148d6e4a/636b6aa9b697b
%%~kind: NOVEL/SCENE
%%~
### Making a Scene
@pov: Jane
+3 -1
View File
@@ -1,4 +1,6 @@
%%~ 04468803b92e1:60bdf227455cc:WORLD:NOTE:Ancient Europe
%%~name: Ancient Europe
%%~path: 60bdf227455cc/04468803b92e1
%%~kind: WORLD/NOTE
# Ancient Europe
@tag: Europe
+3 -1
View File
@@ -1,4 +1,6 @@
%%~ 2426c6f0ca922:6c6afb1247750:PLOT:NOTE:Main
%%~name: Main
%%~path: 6c6afb1247750/2426c6f0ca922
%%~kind: PLOT/NOTE
# Main Plot
@tag: Main
+3 -1
View File
@@ -1,4 +1,6 @@
%%~ 441420a886d82:6bd935d2490cd:b3643d0f92e32:NOVEL:CHAPTER:Chapter Two
%%~name: Chapter Two
%%~path: 6bd935d2490cd/441420a886d82
%%~kind: NOVEL/CHAPTER
## Chapter Two
@pov: Bod
+3 -1
View File
@@ -1,4 +1,6 @@
%%~ 47666c91c7ccf:6bd935d2490cd:b3643d0f92e32:NOVEL:SCENE:Scene Five
%%~name: Scene Five
%%~path: 6bd935d2490cd/47666c91c7ccf
%%~kind: NOVEL/SCENE
### Scene Five
@pov: Bod
+3 -1
View File
@@ -1,4 +1,6 @@
%%~ 4c4f28287af27:67a8707f2f249:CHARACTER:NOTE:Mr. Nobody
%%~name: Mr. Nobody
%%~path: 67a8707f2f249/4c4f28287af27
%%~kind: CHARACTER/NOTE
# Nobody Owens
@tag: Bod
+3 -1
View File
@@ -1,4 +1,6 @@
%%~ 7a992350f3eb6:b3643d0f92e32:NOVEL:TITLE:Lorem Ipusm
%%~name: Lorem Ipsum
%%~path: b3643d0f92e32/7a992350f3eb6
%%~kind: NOVEL/TITLE
# Lorem Ipsum
**By lipsum.com**
+3 -1
View File
@@ -1,4 +1,6 @@
%%~ 846352075de7d:b3643d0f92e32:NOVEL:BOOK:Interlude
%%~name: Interlude
%%~path: b3643d0f92e32/846352075de7d
%%~kind: NOVEL/BOOK
## Why do we use it?
% Exctracted from the lipsum.com website.
+3 -1
View File
@@ -1,4 +1,6 @@
%%~ 88243afbe5ed8:45e6b01ca35c1:b3643d0f92e32:NOVEL:SCENE:Scene One
%%~name: Scene One
%%~path: 45e6b01ca35c1/88243afbe5ed8
%%~kind: NOVEL/SCENE
### Scene One
@pov: Bod
+3 -1
View File
@@ -1,4 +1,6 @@
%%~ 88d59a277361b:b3643d0f92e32:NOVEL:UNNUMBERED:Prologue
%%~name: Prologue
%%~path: b3643d0f92e32/88d59a277361b
%%~kind: NOVEL/UNNUMBERED
## Prologue
% Synopsis:Explanation from the lipsum.com website.
+3 -1
View File
@@ -1,4 +1,6 @@
%%~ 8c58a65414c23:b3643d0f92e32:NOVEL:PAGE:Front Matter
%%~name: Front Matter
%%~path: b3643d0f92e32/8c58a65414c23
%%~kind: NOVEL/PAGE
% Exctracted from the lipsum.com website.
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.
+3 -1
View File
@@ -1,4 +1,6 @@
%%~ db7e733775d4d:b3643d0f92e32:NOVEL:PARTITION:Act One
%%~name: Act One
%%~path: b3643d0f92e32/db7e733775d4d
%%~kind: NOVEL/PARTITION
# Act One
“Fusce maximus felis libero”
+3 -1
View File
@@ -1,4 +1,6 @@
%%~ eb103bc70c90c:6bd935d2490cd:b3643d0f92e32:NOVEL:SCENE:Scene Three
%%~name: Scene Three
%%~path: 6bd935d2490cd/eb103bc70c90c
%%~kind: NOVEL/SCENE
### Scene Three
@pov: Bod
+3 -1
View File
@@ -1,4 +1,6 @@
%%~ f8c0562e50f1b:6bd935d2490cd:b3643d0f92e32:NOVEL:SCENE:Scene Four
%%~name: Scene Four
%%~path: 6bd935d2490cd/f8c0562e50f1b
%%~kind: NOVEL/SCENE
### Scene Four
@pov: Bod
+3 -1
View File
@@ -1,4 +1,6 @@
%%~ f96ec11c6a3da:45e6b01ca35c1:b3643d0f92e32:NOVEL:SCENE:Scene Two
%%~name: Scene Two
%%~path: 45e6b01ca35c1/f96ec11c6a3da
%%~kind: NOVEL/SCENE
### Scene Two
@pov: Bod
+3 -1
View File
@@ -1,4 +1,6 @@
%%~ fb609cd8319dc:45e6b01ca35c1:b3643d0f92e32:NOVEL:CHAPTER:Chapter One
%%~name: Chapter One
%%~path: 45e6b01ca35c1/fb609cd8319dc
%%~kind: NOVEL/CHAPTER
## Chapter One
@pov: Bod
+4 -4
View File
@@ -1,19 +1,19 @@
<?xml version='1.0' encoding='utf-8'?>
<novelWriterXML appVersion="1.0b3" hexVersion="0x010000b3" fileVersion="1.2" timeStamp="2020-10-04 19:00:34">
<novelWriterXML appVersion="1.0b5" hexVersion="0x010000b5" fileVersion="1.2" timeStamp="2020-10-24 18:43:56">
<project>
<name>Lorem Ipsum</name>
<title>Lorem Ipsum</title>
<author>lipsum.com</author>
<saveCount>9</saveCount>
<saveCount>10</saveCount>
<autoCount>22</autoCount>
<editTime>1552</editTime>
<editTime>1571</editTime>
</project>
<settings>
<doBackup>False</doBackup>
<spellCheck>False</spellCheck>
<spellLang>None</spellLang>
<autoOutline>True</autoOutline>
<lastEdited>846352075de7d</lastEdited>
<lastEdited>04468803b92e1</lastEdited>
<lastViewed>None</lastViewed>
<lastWordCount>3847</lastWordCount>
<novelWordCount>3109</novelWordCount>
+3 -1
View File
@@ -1,3 +1,5 @@
%%~ 8c659a11cd429:a6d311a93600a:a508bb932959c:NOVEL:SCENE:New Scene
%%~name: New Scene
%%~path: a6d311a93600a/8c659a11cd429
%%~kind: NOVEL/SCENE
### New Scene
+3 -1
View File
@@ -1,4 +1,6 @@
%%~ a35baf2e93843:a508bb932959c:NOVEL:TITLE:Title Page
%%~name: Title Page
%%~path: a508bb932959c/a35baf2e93843
%%~kind: NOVEL/TITLE
# Minimal
By Jane Doe, John Doh
+3 -1
View File
@@ -1,3 +1,5 @@
%%~ f5ab3e30151e1:a6d311a93600a:a508bb932959c:NOVEL:CHAPTER:New Chapter
%%~name: New Chapter
%%~path: a6d311a93600a/f5ab3e30151e1
%%~kind: NOVEL/CHAPTER
## New Chapter
+7 -6
View File
@@ -1,17 +1,18 @@
<?xml version='1.0' encoding='utf-8'?>
<novelWriterXML appVersion="0.12.1" hexVersion="0x001201f0" fileVersion="1.2" timeStamp="2020-08-28 11:36:45">
<novelWriterXML appVersion="1.0b5" hexVersion="0x010000b5" fileVersion="1.2" timeStamp="2020-10-24 18:55:14">
<project>
<name>Test Minimal</name>
<title>Minimal</title>
<author>Jane Doe</author>
<author>John Doh</author>
<saveCount>1</saveCount>
<saveCount>3</saveCount>
<autoCount>1</autoCount>
<editTime>8</editTime>
<editTime>33</editTime>
</project>
<settings>
<doBackup>True</doBackup>
<spellCheck>False</spellCheck>
<spellLang>None</spellLang>
<autoOutline>True</autoOutline>
<lastEdited>None</lastEdited>
<lastViewed>None</lastViewed>
@@ -57,7 +58,7 @@
<charCount>28</charCount>
<wordCount>6</wordCount>
<paraCount>1</paraCount>
<cursorPos>0</cursorPos>
<cursorPos>33</cursorPos>
</item>
<item handle="a6d311a93600a" order="1" parent="a508bb932959c">
<name>New Chapter</name>
@@ -76,7 +77,7 @@
<charCount>11</charCount>
<wordCount>2</wordCount>
<paraCount>0</paraCount>
<cursorPos>0</cursorPos>
<cursorPos>16</cursorPos>
</item>
<item handle="8c659a11cd429" order="1" parent="a6d311a93600a">
<name>New Scene</name>
@@ -88,7 +89,7 @@
<charCount>9</charCount>
<wordCount>2</wordCount>
<paraCount>0</paraCount>
<cursorPos>0</cursorPos>
<cursorPos>15</cursorPos>
</item>
<item handle="7695ce551d265" order="1" parent="None">
<name>Plot</name>
+3 -1
View File
@@ -1,4 +1,6 @@
%%~ 031b4af5197ec:44cb730c42048:PLOT:NOTE:New File
%%~name: New File
%%~path: 44cb730c42048/031b4af5197ec
%%~kind: PLOT/NOTE
# Main Plot
@tag: MainPlot
+3 -1
View File
@@ -1,4 +1,6 @@
%%~ 0e17daca5f3e1:31489056e0916:73475cb40a568:NOVEL:SCENE:New Scene
%%~name: New Scene
%%~path: 31489056e0916/0e17daca5f3e1
%%~kind: NOVEL/SCENE
# Novel
## Chapter
+3 -1
View File
@@ -1,4 +1,6 @@
%%~ 1a6562590ef19:71ee45a3c0db9:CHARACTER:NOTE:New File
%%~name: New File
%%~path: 71ee45a3c0db9/1a6562590ef19
%%~kind: CHARACTER/NOTE
# Jane Doe
@tag: Jane
+3 -1
View File
@@ -1,4 +1,6 @@
%%~ 41cfc0d1f2d12:811786ad1ae74:WORLD:NOTE:New File
%%~name: New File
%%~path: 811786ad1ae74/41cfc0d1f2d12
%%~kind: WORLD/NOTE
# Main Location
@tag: Home
+3 -1
View File
@@ -1,4 +1,6 @@
%%~ 73475cb40a568:b3643d0f92e32:NOVEL:SCENE:Chapter One
%%~name: Chapter One
%%~path: b3643d0f92e32/73475cb40a568
%%~kind: NOVEL/SCENE
## Chapter One
@pov: Bod
+3 -1
View File
@@ -1,4 +1,6 @@
%%~ 031b4af5197ec:0e17daca5f3e1:b3643d0f92e32:NOVEL:SCENE:Scene One
%%~name: Scene One
%%~path: 0e17daca5f3e1/031b4af5197ec
%%~kind: NOVEL/SCENE
### Scene One
@pov: Bod
+3 -1
View File
@@ -1,4 +1,6 @@
%%~ 25fc0e7096fc6:811786ad1ae74:b3643d0f92e32:NOVEL:CHAPTER:Chapter One
%%~name: Chapter One
%%~path: 811786ad1ae74/25fc0e7096fc6
%%~kind: NOVEL/CHAPTER
## Chapter One
@pov: Bod
+3 -1
View File
@@ -1,4 +1,6 @@
%%~ 2858dcd1057d3:0e17daca5f3e1:b3643d0f92e32:NOVEL:SCENE:Scene Two
%%~name: Scene Two
%%~path: 0e17daca5f3e1/2858dcd1057d3
%%~kind: NOVEL/SCENE
### Scene Two
@pov: Bod
+3 -1
View File
@@ -1,4 +1,6 @@
%%~ 2fca346db6561:0e17daca5f3e1:b3643d0f92e32:NOVEL:SCENE:Scene Two, Section Two
%%~name: Scene Two, Section Two
%%~path: 0e17daca5f3e1/2fca346db6561
%%~kind: NOVEL/SCENE
#### Scene Two, Section Two
Suspendisse potenti. Fusce tempus lorem nec laoreet suscipit. Fusce vulputate nisl ac diam tincidunt, nec malesuada quam pellentesque. Maecenas congue, tellus quis commodo rutrum, magna leo egestas arcu, quis suscipit ex risus id ligula. Suspendisse potenti. Morbi blandit lacus vitae laoreet vulputate. Donec vitae tellus eleifend, lobortis eros eu, tincidunt enim. Nullam et ullamcorper nisi. Vivamus tellus ex, lobortis quis rutrum ut, dapibus sit amet turpis. Phasellus pellentesque metus diam, commodo tristique ante commodo ac. Ut mollis ipsum nec diam blandit sollicitudin. Duis bibendum lacus nec commodo dapibus. Sed condimentum luctus ante, id ultricies urna varius nec. Nam convallis magna nec bibendum ultrices. Orci varius natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Sed auctor pharetra quam, vitae porta ex bibendum eu.
+3 -1
View File
@@ -1,4 +1,6 @@
%%~ 31489056e0916:811786ad1ae74:b3643d0f92e32:NOVEL:SCENE:Scene One
%%~name: Scene One
%%~path: 811786ad1ae74/31489056e0916
%%~kind: NOVEL/SCENE
### Scene One
@pov: Bod
+3 -1
View File
@@ -1,4 +1,6 @@
%%~ 41cfc0d1f2d12:0e17daca5f3e1:b3643d0f92e32:NOVEL:SCENE:Scene One, Section Two
%%~name: Scene One, Section Two
%%~path: 0e17daca5f3e1/41cfc0d1f2d12
%%~kind: NOVEL/SCENE
#### Scene One, Section Two
Integer vel libero ipsum. Donec varius aliquam libero, sit amet commodo urna hendrerit non. Nullam quis erat mollis nunc viverra volutpat tincidunt in odio. Nam vitae quam sem. Aliquam suscipit nulla non lorem pharetra semper. Ut suscipit erat eu ligula accumsan ultrices. Phasellus nisl tellus, placerat sed laoreet id, consectetur nec dolor. Sed fringilla ipsum id dapibus posuere. Aenean finibus pharetra tincidunt. Ut molestie malesuada nulla, id posuere lorem tincidunt eu. Aliquam tempor eros a est vulputate, scelerisque pulvinar ipsum fermentum. In hac habitasse platea dictumst.
+3 -1
View File
@@ -1,4 +1,6 @@
%%~ 98010bd9270f9:811786ad1ae74:b3643d0f92e32:NOVEL:SCENE:Scene Two
%%~name: Scene Two
%%~path: 811786ad1ae74/98010bd9270f9
%%~kind: NOVEL/SCENE
### Scene Two
@pov: Bod
+2 -2
View File
@@ -640,7 +640,7 @@ def testMergeSplitTools(qtbot, monkeypatch, yesToAll, nwTempGUI, nwLipsum, nwRef
testFile = os.path.join(nwTempGUI, "4_71ee45a3c0db9.nwd")
refFile = os.path.join(nwRef, "gui", "4_73475cb40a568.nwd")
copyfile(projFile, testFile)
assert cmpFiles(testFile, refFile, [1])
assert cmpFiles(testFile, refFile, [1, 2, 3])
# Split By Scene
assert nwGUI.treeView.setSelectedHandle("73475cb40a568")
@@ -702,7 +702,7 @@ def testMergeSplitTools(qtbot, monkeypatch, yesToAll, nwTempGUI, nwLipsum, nwRef
testFile = os.path.join(nwTempGUI, "5_25fc0e7096fc6.nwd")
refFile = os.path.join(nwRef, "gui", "5_25fc0e7096fc6.nwd")
copyfile(projFile, testFile)
assert cmpFiles(testFile, refFile, [1])
assert cmpFiles(testFile, refFile, [1, 2, 3])
projFile = os.path.join(nwLipsum, "content", "031b4af5197ec.nwd")
testFile = os.path.join(nwTempGUI, "5_031b4af5197ec.nwd")
-10
View File
@@ -684,16 +684,6 @@ def testProjectTree(qtbot, yesToAll, nwMinimal, nwTemp):
orItem = nwTree._getTreeItem("1234567890abc")
assert orItem.text(nwTree.C_NAME) == "Orphaned File 1"
# Move it to the Plot folder
# plItem = nwTree._getTreeItem("7695ce551d265")
# orRect = nwTree.visualItemRect(orItem)
# plRect = nwTree.visualItemRect(plItem)
# qtbot.mouseMove(nwTree.viewport(), pos=orRect.center(), delay=1000)
# qtbot.mousePress(nwTree.viewport(), Qt.LeftButton, pos=orRect.center(), delay=1000)
# qtbot.mouseMove(nwTree.viewport(), pos=plRect.center(), delay=1000)
# qtbot.mouseRelease(nwTree.viewport(), Qt.LeftButton, pos=plRect.center(), delay=1000)
# qtbot.stopForInteraction()
nwGUI.closeMain()
nwGUI.close()
+10 -11
View File
@@ -335,20 +335,17 @@ def testDocMeta(nwDummy, nwLipsum):
aDoc = NWDoc(theProject, nwDummy)
assert aDoc.openDocument("47666c91c7ccf")
theMeta, thePath, theClass, theLayout = aDoc.getMeta()
theName, theParent, theClass, theLayout = aDoc.getMeta()
assert theMeta == "Scene Five"
assert len(thePath) == 3
assert thePath[0] == "47666c91c7ccf"
assert thePath[1] == "6bd935d2490cd"
assert thePath[2] == "b3643d0f92e32"
assert theName == "Scene Five"
assert theParent == "6bd935d2490cd"
assert theClass == nwItemClass.NOVEL
assert theLayout == nwItemLayout.SCENE
aDoc._docMeta = "too_short"
theMeta, thePath, theClass, theLayout = aDoc.getMeta()
assert theMeta == ""
assert thePath == []
aDoc._docMeta = {"stuff": None}
theName, theParent, theClass, theLayout = aDoc.getMeta()
assert theName == ""
assert theParent is None
assert theClass is None
assert theLayout is None
@@ -488,7 +485,9 @@ def testProjectOrphanedFiles(nwDummy, nwLipsum):
# First Item with Meta Data
orphPath = os.path.join(nwLipsum, "content", "636b6aa9b697b.nwd")
with open(orphPath, mode="w", encoding="utf8") as outFile:
outFile.write(r"%%~ 5eaea4e8cdee8:15c4492bd5107:WORLD:NOTE:Mars")
outFile.write("%%~name:Mars\n")
outFile.write("%%~path:5eaea4e8cdee8/636b6aa9b697b\n")
outFile.write("%%~kind:WORLD/NOTE\n")
outFile.write("\n")
# Second Item without Meta Data