Fix tests

This commit is contained in:
Veronica K. B. Olsen
2021-01-30 18:54:30 +01:00
parent 087735a08f
commit 7a3c33fde3
16 changed files with 38 additions and 15 deletions
+1
View File
@@ -1,6 +1,7 @@
%%~name: Making a Scene %%~name: Making a Scene
%%~path: e7ded148d6e4a/636b6aa9b697b %%~path: e7ded148d6e4a/636b6aa9b697b
%%~kind: NOVEL/SCENE %%~kind: NOVEL/SCENE
%%~time: 2021-01-30 18:30:48
### Making a Scene ### Making a Scene
@pov: Jane @pov: Jane
@@ -1,6 +1,7 @@
%%~name: New File %%~name: New File
%%~path: 44cb730c42048/031b4af5197ec %%~path: 44cb730c42048/031b4af5197ec
%%~kind: PLOT/NOTE %%~kind: PLOT/NOTE
%%~time: 2021-01-30 18:49:59
# Main Plot # Main Plot
@tag: MainPlot @tag: MainPlot
@@ -1,6 +1,7 @@
%%~name: New Scene %%~name: New Scene
%%~path: 31489056e0916/0e17daca5f3e1 %%~path: 31489056e0916/0e17daca5f3e1
%%~kind: NOVEL/BOOK %%~kind: NOVEL/BOOK
%%~time: 2021-01-30 18:51:35
# Novel # Novel
## Chapter ## Chapter
@@ -1,6 +1,7 @@
%%~name: New File %%~name: New File
%%~path: 71ee45a3c0db9/1a6562590ef19 %%~path: 71ee45a3c0db9/1a6562590ef19
%%~kind: CHARACTER/NOTE %%~kind: CHARACTER/NOTE
%%~time: 2021-01-30 18:51:04
# Jane Doe # Jane Doe
@tag: Jane @tag: Jane
@@ -1,6 +1,7 @@
%%~name: New File %%~name: New File
%%~path: 811786ad1ae74/41cfc0d1f2d12 %%~path: 811786ad1ae74/41cfc0d1f2d12
%%~kind: WORLD/NOTE %%~kind: WORLD/NOTE
%%~time: 2021-01-30 18:51:53
# Main Location # Main Location
@tag: Home @tag: Home
@@ -1,6 +1,7 @@
%%~name: Chapter One %%~name: Chapter One
%%~path: b3643d0f92e32/73475cb40a568 %%~path: b3643d0f92e32/73475cb40a568
%%~kind: NOVEL/SCENE %%~kind: NOVEL/SCENE
%%~time: 2021-01-30 18:39:07
## Chapter One ## Chapter One
@pov: Bod @pov: Bod
@@ -1,6 +1,7 @@
%%~name: Scene One %%~name: Scene One
%%~path: 0e17daca5f3e1/031b4af5197ec %%~path: 0e17daca5f3e1/031b4af5197ec
%%~kind: NOVEL/SCENE %%~kind: NOVEL/SCENE
%%~time: 2021-01-30 18:42:30
### Scene One ### Scene One
@pov: Bod @pov: Bod
@@ -1,6 +1,7 @@
%%~name: Chapter One %%~name: Chapter One
%%~path: 811786ad1ae74/25fc0e7096fc6 %%~path: 811786ad1ae74/25fc0e7096fc6
%%~kind: NOVEL/CHAPTER %%~kind: NOVEL/CHAPTER
%%~time: 2021-01-30 18:40:32
## Chapter One ## Chapter One
@pov: Bod @pov: Bod
@@ -1,6 +1,7 @@
%%~name: Scene Two %%~name: Scene Two
%%~path: 0e17daca5f3e1/2858dcd1057d3 %%~path: 0e17daca5f3e1/2858dcd1057d3
%%~kind: NOVEL/SCENE %%~kind: NOVEL/SCENE
%%~time: 2021-01-30 18:43:17
### Scene Two ### Scene Two
@pov: Bod @pov: Bod
@@ -1,6 +1,7 @@
%%~name: Scene Two, Section Two %%~name: Scene Two, Section Two
%%~path: 0e17daca5f3e1/2fca346db6561 %%~path: 0e17daca5f3e1/2fca346db6561
%%~kind: NOVEL/SCENE %%~kind: NOVEL/SCENE
%%~time: 2021-01-30 18:43:30
#### Scene Two, Section Two #### 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. 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.
@@ -1,6 +1,7 @@
%%~name: Scene One %%~name: Scene One
%%~path: 811786ad1ae74/31489056e0916 %%~path: 811786ad1ae74/31489056e0916
%%~kind: NOVEL/SCENE %%~kind: NOVEL/SCENE
%%~time: 2021-01-30 18:41:22
### Scene One ### Scene One
@pov: Bod @pov: Bod
@@ -1,6 +1,7 @@
%%~name: Scene One, Section Two %%~name: Scene One, Section Two
%%~path: 0e17daca5f3e1/41cfc0d1f2d12 %%~path: 0e17daca5f3e1/41cfc0d1f2d12
%%~kind: NOVEL/SCENE %%~kind: NOVEL/SCENE
%%~time: 2021-01-30 18:43:04
#### Scene One, Section Two #### 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. 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.
@@ -1,6 +1,7 @@
%%~name: Scene Two %%~name: Scene Two
%%~path: 811786ad1ae74/98010bd9270f9 %%~path: 811786ad1ae74/98010bd9270f9
%%~kind: NOVEL/SCENE %%~kind: NOVEL/SCENE
%%~time: 2021-01-30 18:41:48
### Scene Two ### Scene Two
@pov: Bod @pov: Bod
+6
View File
@@ -28,6 +28,7 @@ from dummy import causeOSError
from nw.core import NWProject, NWDoc from nw.core import NWProject, NWDoc
from nw.core.item import NWItem from nw.core.item import NWItem
from nw.constants import nwItemClass, nwItemLayout from nw.constants import nwItemClass, nwItemLayout
from nw.common import formatTimeStamp
@pytest.mark.core @pytest.mark.core
def testCoreDocument_LoadSave(monkeypatch, dummyGUI, nwMinimal): def testCoreDocument_LoadSave(monkeypatch, dummyGUI, nwMinimal):
@@ -74,6 +75,7 @@ def testCoreDocument_LoadSave(monkeypatch, dummyGUI, nwMinimal):
assert theDoc.saveDocument(theText) assert theDoc.saveDocument(theText)
# Save again to ensure temp file and previous file is handled # Save again to ensure temp file and previous file is handled
monkeypatch.setattr("nw.core.document.time", lambda: 123.4)
assert theDoc.saveDocument(theText) assert theDoc.saveDocument(theText)
# Check file content # Check file content
@@ -83,9 +85,11 @@ def testCoreDocument_LoadSave(monkeypatch, dummyGUI, nwMinimal):
"%%~name: New File\n" "%%~name: New File\n"
f"%%~path: a508bb932959c/{xHandle}\n" f"%%~path: a508bb932959c/{xHandle}\n"
"%%~kind: NOVEL/SCENE\n" "%%~kind: NOVEL/SCENE\n"
f"%%~time: {formatTimeStamp(123.4)}\n"
"### Test File\n\n" "### Test File\n\n"
"Text ...\n\n" "Text ...\n\n"
) )
monkeypatch.undo()
# Force no meta data # Force no meta data
theDoc._theItem = None theDoc._theItem = None
@@ -147,12 +151,14 @@ def testCoreDocument_Methods(monkeypatch, dummyGUI, nwMinimal):
assert theLayout == nwItemLayout.SCENE assert theLayout == nwItemLayout.SCENE
# Add meta data garbage # Add meta data garbage
monkeypatch.setattr("nw.core.document.time", lambda: 123.4)
assert theDoc.saveDocument("%%~ stuff\n### Test File\n\nText ...\n\n") assert theDoc.saveDocument("%%~ stuff\n### Test File\n\nText ...\n\n")
with open(docPath, mode="r", encoding="utf8") as inFile: with open(docPath, mode="r", encoding="utf8") as inFile:
assert inFile.read() == ( assert inFile.read() == (
"%%~name: New Scene\n" "%%~name: New Scene\n"
f"%%~path: a6d311a93600a/{sHandle}\n" f"%%~path: a6d311a93600a/{sHandle}\n"
"%%~kind: NOVEL/SCENE\n" "%%~kind: NOVEL/SCENE\n"
f"%%~time: {formatTimeStamp(123.4)}\n"
"%%~ stuff\n" "%%~ stuff\n"
"### Test File\n\n" "### Test File\n\n"
"Text ...\n\n" "Text ...\n\n"
+9 -5
View File
@@ -28,8 +28,9 @@ from tools import cmpFiles
from PyQt5.QtCore import Qt from PyQt5.QtCore import Qt
from PyQt5.QtGui import QTextCursor from PyQt5.QtGui import QTextCursor
from PyQt5.QtWidgets import QAction, QMessageBox from PyQt5.QtWidgets import QAction, QMessageBox, QDialog
from nw.gui.itemeditor import GuiItemEditor
from nw.constants import nwItemType, nwDocAction from nw.constants import nwItemType, nwDocAction
keyDelay = 2 keyDelay = 2
@@ -42,6 +43,9 @@ def testGuiEditor_Main(qtbot, monkeypatch, nwGUI, fncDir, fncProj, refDir, outDi
""" """
# Block message box # Block message box
monkeypatch.setattr(QMessageBox, "question", lambda *args: QMessageBox.Yes) monkeypatch.setattr(QMessageBox, "question", lambda *args: QMessageBox.Yes)
monkeypatch.setattr(QMessageBox, "information", lambda *args: QMessageBox.Yes)
monkeypatch.setattr(GuiItemEditor, "exec_", lambda *args: None)
monkeypatch.setattr(GuiItemEditor, "result", lambda *args: QDialog.Accepted)
# Create new, save, close project # Create new, save, close project
nwGUI.theProject.projTree.setSeed(42) nwGUI.theProject.projTree.setSeed(42)
@@ -321,25 +325,25 @@ def testGuiEditor_Main(qtbot, monkeypatch, nwGUI, fncDir, fncProj, refDir, outDi
testFile = os.path.join(outDir, "guiEditor_Main_Final_031b4af5197ec.nwd") testFile = os.path.join(outDir, "guiEditor_Main_Final_031b4af5197ec.nwd")
compFile = os.path.join(refDir, "guiEditor_Main_Final_031b4af5197ec.nwd") compFile = os.path.join(refDir, "guiEditor_Main_Final_031b4af5197ec.nwd")
copyfile(projFile, testFile) copyfile(projFile, testFile)
assert cmpFiles(testFile, compFile) assert cmpFiles(testFile, compFile, [4])
projFile = os.path.join(fncProj, "content", "1a6562590ef19.nwd") projFile = os.path.join(fncProj, "content", "1a6562590ef19.nwd")
testFile = os.path.join(outDir, "guiEditor_Main_Final_1a6562590ef19.nwd") testFile = os.path.join(outDir, "guiEditor_Main_Final_1a6562590ef19.nwd")
compFile = os.path.join(refDir, "guiEditor_Main_Final_1a6562590ef19.nwd") compFile = os.path.join(refDir, "guiEditor_Main_Final_1a6562590ef19.nwd")
copyfile(projFile, testFile) copyfile(projFile, testFile)
assert cmpFiles(testFile, compFile) assert cmpFiles(testFile, compFile, [4])
projFile = os.path.join(fncProj, "content", "0e17daca5f3e1.nwd") projFile = os.path.join(fncProj, "content", "0e17daca5f3e1.nwd")
testFile = os.path.join(outDir, "guiEditor_Main_Final_0e17daca5f3e1.nwd") testFile = os.path.join(outDir, "guiEditor_Main_Final_0e17daca5f3e1.nwd")
compFile = os.path.join(refDir, "guiEditor_Main_Final_0e17daca5f3e1.nwd") compFile = os.path.join(refDir, "guiEditor_Main_Final_0e17daca5f3e1.nwd")
copyfile(projFile, testFile) copyfile(projFile, testFile)
assert cmpFiles(testFile, compFile) assert cmpFiles(testFile, compFile, [4])
projFile = os.path.join(fncProj, "content", "41cfc0d1f2d12.nwd") projFile = os.path.join(fncProj, "content", "41cfc0d1f2d12.nwd")
testFile = os.path.join(outDir, "guiEditor_Main_Final_41cfc0d1f2d12.nwd") testFile = os.path.join(outDir, "guiEditor_Main_Final_41cfc0d1f2d12.nwd")
compFile = os.path.join(refDir, "guiEditor_Main_Final_41cfc0d1f2d12.nwd") compFile = os.path.join(refDir, "guiEditor_Main_Final_41cfc0d1f2d12.nwd")
copyfile(projFile, testFile) copyfile(projFile, testFile)
assert cmpFiles(testFile, compFile) assert cmpFiles(testFile, compFile, [4])
# qtbot.stopForInteraction() # qtbot.stopForInteraction()
+10 -10
View File
@@ -66,7 +66,7 @@ def testGuiMergeSplit_Tools(qtbot, monkeypatch, nwGUI, nwLipsum, refDir, outDir)
testFile = os.path.join(outDir, "guiMerge_73475cb40a568.nwd") testFile = os.path.join(outDir, "guiMerge_73475cb40a568.nwd")
compFile = os.path.join(refDir, "guiMerge_73475cb40a568.nwd") compFile = os.path.join(refDir, "guiMerge_73475cb40a568.nwd")
copyfile(projFile, testFile) copyfile(projFile, testFile)
assert cmpFiles(testFile, compFile) assert cmpFiles(testFile, compFile, [4])
# Split By Chapter # Split By Chapter
assert nwGUI.treeView.setSelectedHandle("73475cb40a568") assert nwGUI.treeView.setSelectedHandle("73475cb40a568")
@@ -92,7 +92,7 @@ def testGuiMergeSplit_Tools(qtbot, monkeypatch, nwGUI, nwLipsum, refDir, outDir)
testFile = os.path.join(outDir, "guiMerge_71ee45a3c0db9.nwd") testFile = os.path.join(outDir, "guiMerge_71ee45a3c0db9.nwd")
compFile = os.path.join(refDir, "guiMerge_73475cb40a568.nwd") compFile = os.path.join(refDir, "guiMerge_73475cb40a568.nwd")
copyfile(projFile, testFile) copyfile(projFile, testFile)
assert cmpFiles(testFile, compFile, [1, 2, 3]) assert cmpFiles(testFile, compFile, [1, 2, 3, 4])
# Split By Scene # Split By Scene
assert nwGUI.treeView.setSelectedHandle("73475cb40a568") assert nwGUI.treeView.setSelectedHandle("73475cb40a568")
@@ -116,19 +116,19 @@ def testGuiMergeSplit_Tools(qtbot, monkeypatch, nwGUI, nwLipsum, refDir, outDir)
testFile = os.path.join(outDir, "guiSplit_25fc0e7096fc6.nwd") testFile = os.path.join(outDir, "guiSplit_25fc0e7096fc6.nwd")
compFile = os.path.join(refDir, "guiSplit_25fc0e7096fc6.nwd") compFile = os.path.join(refDir, "guiSplit_25fc0e7096fc6.nwd")
copyfile(projFile, testFile) copyfile(projFile, testFile)
assert cmpFiles(testFile, compFile) assert cmpFiles(testFile, compFile, [4])
projFile = os.path.join(nwLipsum, "content", "31489056e0916.nwd") projFile = os.path.join(nwLipsum, "content", "31489056e0916.nwd")
testFile = os.path.join(outDir, "guiSplit_31489056e0916.nwd") testFile = os.path.join(outDir, "guiSplit_31489056e0916.nwd")
compFile = os.path.join(refDir, "guiSplit_31489056e0916.nwd") compFile = os.path.join(refDir, "guiSplit_31489056e0916.nwd")
copyfile(projFile, testFile) copyfile(projFile, testFile)
assert cmpFiles(testFile, compFile) assert cmpFiles(testFile, compFile, [4])
projFile = os.path.join(nwLipsum, "content", "98010bd9270f9.nwd") projFile = os.path.join(nwLipsum, "content", "98010bd9270f9.nwd")
testFile = os.path.join(outDir, "guiSplit_98010bd9270f9.nwd") testFile = os.path.join(outDir, "guiSplit_98010bd9270f9.nwd")
compFile = os.path.join(refDir, "guiSplit_98010bd9270f9.nwd") compFile = os.path.join(refDir, "guiSplit_98010bd9270f9.nwd")
copyfile(projFile, testFile) copyfile(projFile, testFile)
assert cmpFiles(testFile, compFile) assert cmpFiles(testFile, compFile, [4])
# Split By Section # Split By Section
assert nwGUI.treeView.setSelectedHandle("73475cb40a568") assert nwGUI.treeView.setSelectedHandle("73475cb40a568")
@@ -154,31 +154,31 @@ def testGuiMergeSplit_Tools(qtbot, monkeypatch, nwGUI, nwLipsum, refDir, outDir)
testFile = os.path.join(outDir, "guiSplit_1a6562590ef19.nwd") testFile = os.path.join(outDir, "guiSplit_1a6562590ef19.nwd")
compFile = os.path.join(refDir, "guiSplit_25fc0e7096fc6.nwd") compFile = os.path.join(refDir, "guiSplit_25fc0e7096fc6.nwd")
copyfile(projFile, testFile) copyfile(projFile, testFile)
assert cmpFiles(testFile, compFile, [1, 2, 3]) assert cmpFiles(testFile, compFile, [1, 2, 3, 4])
projFile = os.path.join(nwLipsum, "content", "031b4af5197ec.nwd") projFile = os.path.join(nwLipsum, "content", "031b4af5197ec.nwd")
testFile = os.path.join(outDir, "guiSplit_031b4af5197ec.nwd") testFile = os.path.join(outDir, "guiSplit_031b4af5197ec.nwd")
compFile = os.path.join(refDir, "guiSplit_031b4af5197ec.nwd") compFile = os.path.join(refDir, "guiSplit_031b4af5197ec.nwd")
copyfile(projFile, testFile) copyfile(projFile, testFile)
assert cmpFiles(testFile, compFile) assert cmpFiles(testFile, compFile, [4])
projFile = os.path.join(nwLipsum, "content", "41cfc0d1f2d12.nwd") projFile = os.path.join(nwLipsum, "content", "41cfc0d1f2d12.nwd")
testFile = os.path.join(outDir, "guiSplit_41cfc0d1f2d12.nwd") testFile = os.path.join(outDir, "guiSplit_41cfc0d1f2d12.nwd")
compFile = os.path.join(refDir, "guiSplit_41cfc0d1f2d12.nwd") compFile = os.path.join(refDir, "guiSplit_41cfc0d1f2d12.nwd")
copyfile(projFile, testFile) copyfile(projFile, testFile)
assert cmpFiles(testFile, compFile) assert cmpFiles(testFile, compFile, [4])
projFile = os.path.join(nwLipsum, "content", "2858dcd1057d3.nwd") projFile = os.path.join(nwLipsum, "content", "2858dcd1057d3.nwd")
testFile = os.path.join(outDir, "guiSplit_2858dcd1057d3.nwd") testFile = os.path.join(outDir, "guiSplit_2858dcd1057d3.nwd")
compFile = os.path.join(refDir, "guiSplit_2858dcd1057d3.nwd") compFile = os.path.join(refDir, "guiSplit_2858dcd1057d3.nwd")
copyfile(projFile, testFile) copyfile(projFile, testFile)
assert cmpFiles(testFile, compFile) assert cmpFiles(testFile, compFile, [4])
projFile = os.path.join(nwLipsum, "content", "2fca346db6561.nwd") projFile = os.path.join(nwLipsum, "content", "2fca346db6561.nwd")
testFile = os.path.join(outDir, "guiSplit_2fca346db6561.nwd") testFile = os.path.join(outDir, "guiSplit_2fca346db6561.nwd")
compFile = os.path.join(refDir, "guiSplit_2fca346db6561.nwd") compFile = os.path.join(refDir, "guiSplit_2fca346db6561.nwd")
copyfile(projFile, testFile) copyfile(projFile, testFile)
assert cmpFiles(testFile, compFile) assert cmpFiles(testFile, compFile, [4])
# qtbot.stopForInteraction() # qtbot.stopForInteraction()