Core classes should only init with project class and if needed access main gui via project

This commit is contained in:
Veronica K. B. Olsen
2021-04-25 17:39:52 +02:00
parent 45f726669e
commit 48695651e1
19 changed files with 56 additions and 61 deletions
+2 -2
View File
@@ -37,7 +37,7 @@ def testCoreDocument_LoadSave(monkeypatch, dummyGUI, nwMinimal):
assert theProject.openProject(nwMinimal)
assert theProject.projPath == nwMinimal
theDoc = NWDoc(theProject, dummyGUI)
theDoc = NWDoc(theProject)
sHandle = "8c659a11cd429"
# Not a valid handle
@@ -126,7 +126,7 @@ def testCoreDocument_Methods(monkeypatch, dummyGUI, nwMinimal):
assert theProject.openProject(nwMinimal)
assert theProject.projPath == nwMinimal
theDoc = NWDoc(theProject, dummyGUI)
theDoc = NWDoc(theProject)
sHandle = "8c659a11cd429"
docPath = os.path.join(nwMinimal, "content", sHandle+".nwd")
+9 -9
View File
@@ -48,7 +48,7 @@ def testCoreIndex_LoadSave(monkeypatch, nwLipsum, dummyGUI, outDir, refDir):
monkeypatch.setattr("nw.core.index.time", lambda: 123.4)
theIndex = NWIndex(theProject, dummyGUI)
theIndex = NWIndex(theProject)
notIndexable = {
"b3643d0f92e32": False, # Novel ROOT
"45e6b01ca35c1": False, # Chapter One FOLDER
@@ -132,7 +132,7 @@ def testCoreIndex_ScanThis(nwMinimal, dummyGUI):
theProject.projTree.setSeed(42)
assert theProject.openProject(nwMinimal)
theIndex = NWIndex(theProject, dummyGUI)
theIndex = NWIndex(theProject)
isValid, theBits, thePos = theIndex.scanThis("tag: this, and this")
assert not isValid
@@ -183,7 +183,7 @@ def testCoreIndex_CheckThese(nwMinimal, dummyGUI):
theProject.projTree.setSeed(42)
assert theProject.openProject(nwMinimal)
theIndex = NWIndex(theProject, dummyGUI)
theIndex = NWIndex(theProject)
nHandle = theProject.newFile("Hello", nwItemClass.NOVEL, "a508bb932959c")
cHandle = theProject.newFile("Jane", nwItemClass.CHARACTER, "afb3043c7b2b3")
nItem = theProject.projTree[nHandle]
@@ -244,7 +244,7 @@ def testCoreIndex_ScanText(nwMinimal, dummyGUI):
theProject.projTree.setSeed(42)
assert theProject.openProject(nwMinimal)
theIndex = NWIndex(theProject, dummyGUI)
theIndex = NWIndex(theProject)
# Some items for fail to scan tests
dHandle = theProject.newFolder("Folder", nwItemClass.NOVEL, "a508bb932959c")
@@ -449,7 +449,7 @@ def testCoreIndex_ExtractData(nwMinimal, dummyGUI):
theProject.projTree.setSeed(42)
assert theProject.openProject(nwMinimal)
theIndex = NWIndex(theProject, dummyGUI)
theIndex = NWIndex(theProject)
nHandle = theProject.newFile("Hello", nwItemClass.NOVEL, "a508bb932959c")
cHandle = theProject.newFile("Jane", nwItemClass.CHARACTER, "afb3043c7b2b3")
@@ -678,7 +678,7 @@ def testCoreIndex_CheckTagIndex(dummyGUI):
"""Test the tag index checker.
"""
theProject = NWProject(dummyGUI)
theIndex = NWIndex(theProject, dummyGUI)
theIndex = NWIndex(theProject)
# Valid Index
theIndex._tagIndex = {
@@ -742,7 +742,7 @@ def testCoreIndex_CheckRefIndex(dummyGUI):
"""Test the reference index checker.
"""
theProject = NWProject(dummyGUI)
theIndex = NWIndex(theProject, dummyGUI)
theIndex = NWIndex(theProject)
# Valid Index
theIndex._refIndex = {
@@ -864,7 +864,7 @@ def testCoreIndex_CheckNovelNoteIndex(dummyGUI):
"""Test the novel and note index checkers.
"""
theProject = NWProject(dummyGUI)
theIndex = NWIndex(theProject, dummyGUI)
theIndex = NWIndex(theProject)
# Valid Index
theIndex._novelIndex = {
@@ -1122,7 +1122,7 @@ def testCoreIndex_CheckTextCounts(dummyGUI):
"""Test the text counts checker.
"""
theProject = NWProject(dummyGUI)
theIndex = NWIndex(theProject, dummyGUI)
theIndex = NWIndex(theProject)
# Valid Index
theIndex._textCounts = {
+6 -6
View File
@@ -32,8 +32,8 @@ def testCoreToHtml_Format(dummyGUI):
"""Test all the formatters for the ToHtml class.
"""
theProject = NWProject(dummyGUI)
dummyGUI.theIndex = NWIndex(theProject, dummyGUI)
theHtml = ToHtml(theProject, dummyGUI)
dummyGUI.theIndex = NWIndex(theProject)
theHtml = ToHtml(theProject)
# Export Mode
# ===========
@@ -84,8 +84,8 @@ def testCoreToHtml_Convert(dummyGUI):
"""Test the converter of the ToHtml class.
"""
theProject = NWProject(dummyGUI)
dummyGUI.theIndex = NWIndex(theProject, dummyGUI)
theHtml = ToHtml(theProject, dummyGUI)
dummyGUI.theIndex = NWIndex(theProject)
theHtml = ToHtml(theProject)
# Export Mode
# ===========
@@ -348,7 +348,7 @@ def testCoreToHtml_Complex(dummyGUI, fncDir):
"""Test the ave method of the ToHtml class.
"""
theProject = NWProject(dummyGUI)
theHtml = ToHtml(theProject, dummyGUI)
theHtml = ToHtml(theProject)
# Build Project
# =============
@@ -421,7 +421,7 @@ def testCoreToHtml_Methods(dummyGUI):
"""Test all the other methods of the ToHtml class.
"""
theProject = NWProject(dummyGUI)
theHtml = ToHtml(theProject, dummyGUI)
theHtml = ToHtml(theProject)
theHtml.setKeepMarkdown(True)
# Auto-Replace, keep Unicode
+5 -5
View File
@@ -33,7 +33,7 @@ def testCoreToken_Setters(dummyGUI):
"""Test all the setters for the Tokenizer class.
"""
theProject = NWProject(dummyGUI)
theToken = Tokenizer(theProject, dummyGUI)
theToken = Tokenizer(theProject)
# Verify defaults
assert theToken.fmtTitle == "%title%"
@@ -120,7 +120,7 @@ def testCoreToken_TextOps(monkeypatch, nwMinimal, dummyGUI):
theProject.projLang = "en"
theProject._loadProjectLocalisation()
theToken = Tokenizer(theProject, dummyGUI)
theToken = Tokenizer(theProject)
theToken.setKeepMarkdown(True)
assert theProject.openProject(nwMinimal)
@@ -137,7 +137,7 @@ def testCoreToken_TextOps(monkeypatch, nwMinimal, dummyGUI):
)
docTextR = docText.replace("<A>", "this").replace("<B>", "that")
nDoc = NWDoc(theProject, dummyGUI)
nDoc = NWDoc(theProject)
nDoc.readDocument(sHandle)
nDoc.writeDocument(docText)
nDoc.clearDocument()
@@ -200,7 +200,7 @@ def testCoreToken_Tokenize(dummyGUI):
"""Test the tokenization of the Tokenizer class.
"""
theProject = NWProject(dummyGUI)
theToken = Tokenizer(theProject, dummyGUI)
theToken = Tokenizer(theProject)
theToken.setKeepMarkdown(True)
# Header 1
@@ -417,7 +417,7 @@ def testCoreToken_Headers(dummyGUI):
theProject = NWProject(dummyGUI)
theProject.projLang = "en"
theProject._loadProjectLocalisation()
theToken = Tokenizer(theProject, dummyGUI)
theToken = Tokenizer(theProject)
# Nothing
theToken.theText = "Some text ...\n"
+2 -2
View File
@@ -48,8 +48,8 @@ def testCoreToOdt_Convert(dummyGUI):
"""Test the converter of the ToHtml class.
"""
theProject = NWProject(dummyGUI)
dummyGUI.theIndex = NWIndex(theProject, dummyGUI)
theDoc = ToOdt(theProject, dummyGUI, isFlat=True)
dummyGUI.theIndex = NWIndex(theProject)
theDoc = ToOdt(theProject, isFlat=True)
# Export Mode
# ===========