Complete loading project xml via data class

This commit is contained in:
Veronica Berglyd Olsen
2022-10-31 18:11:46 +01:00
parent 522acc479b
commit 3a161e90f9
14 changed files with 129 additions and 161 deletions
+11 -11
View File
@@ -941,19 +941,19 @@ def testCoreProject_Methods(monkeypatch, mockGUI, tmpDir, fncDir, mockRnd):
# Spell check
theProject.setProjectChanged(False)
assert theProject.setSpellCheck(True)
assert not theProject.setSpellCheck(False)
theProject.data.setSpellCheck(True)
theProject.data.setSpellCheck(False)
assert theProject.projChanged
# Spell language
theProject.setProjectChanged(False)
assert theProject.projSpell is None
assert theProject.setSpellLang(None) is False
assert theProject.projSpell is None
assert theProject.setSpellLang("None") is False # Should be interpreded as None
assert theProject.projSpell is None
assert theProject.setSpellLang("en_GB")
assert theProject.projSpell == "en_GB"
assert theProject.data.spellLang is None
theProject.data.setSpellLang(None)
assert theProject.data.spellLang is None
theProject.data.setSpellLang("None") # Should be interpreded as None
assert theProject.data.spellLang is None
theProject.data.setSpellLang("en_GB")
assert theProject.data.spellLang == "en_GB"
assert theProject.projChanged
# Project Language
@@ -982,8 +982,8 @@ def testCoreProject_Methods(monkeypatch, mockGUI, tmpDir, fncDir, mockRnd):
# Autoreplace
theProject.setProjectChanged(False)
assert theProject.setAutoReplace({"A": "B", "C": "D"})
assert theProject.autoReplace == {"A": "B", "C": "D"}
theProject.data.setAutoReplace({"A": "B", "C": "D"})
assert theProject.data.autoReplace == {"A": "B", "C": "D"}
assert theProject.projChanged
# Change project tree order
+1 -1
View File
@@ -160,7 +160,7 @@ def testCoreToken_TextOps(monkeypatch, nwMinimal, mockGUI):
nDoc = NWDoc(theProject, sHandle)
assert nDoc.writeDocument(docText)
theProject.setAutoReplace({"A": "this", "B": "that"})
theProject.data.setAutoReplace({"A": "this", "B": "that"})
assert theProject.saveProject()
+6 -6
View File
@@ -50,7 +50,7 @@ def testDlgProjSettings_Dialog(qtbot, monkeypatch, nwGUI):
# Pretend we have a project
nwGUI.hasProject = True
nwGUI.theProject.setSpellLang("en")
nwGUI.theProject.data.setSpellLang("en")
# Get the dialog object
nwGUI.mainMenu.aProjectSettings.activate(QAction.Trigger)
@@ -95,9 +95,9 @@ def testDlgProjSettings_Main(qtbot, monkeypatch, nwGUI, fncDir, fncProj, mockRnd
# Set some values
theProject = nwGUI.theProject
theProject.setSpellLang("en")
theProject.data.setSpellLang("en")
theProject.data.setAuthors("Jane Smith\nJohn Smith")
theProject.setAutoReplace({"A": "B", "C": "D"})
theProject.data.setAutoReplace({"A": "B", "C": "D"})
# Create Dialog
projSettings = GuiProjectSettings(nwGUI, GuiProjectSettings.TAB_MAIN)
@@ -365,9 +365,9 @@ def testDlgProjSettings_Replace(qtbot, monkeypatch, nwGUI, fncDir, fncProj, mock
# Set some values
theProject = nwGUI.theProject
theProject.autoReplace = {
theProject.data.setAutoReplace({
"A": "B", "C": "D"
}
})
# Create Dialog
projSettings = GuiProjectSettings(nwGUI, GuiProjectSettings.TAB_REPLACE)
@@ -429,7 +429,7 @@ def testDlgProjSettings_Replace(qtbot, monkeypatch, nwGUI, fncDir, fncProj, mock
# Check Project
projSettings._doSave()
assert theProject.autoReplace == {
assert theProject.data.autoReplace == {
"A": "B", "C": "D", "This": "With This Stuff"
}
+2 -2
View File
@@ -175,7 +175,7 @@ def testGuiMain_Editing(qtbot, monkeypatch, nwGUI, fncProj, refDir, outDir, mock
assert nwGUI.theProject.data.name == ""
assert nwGUI.theProject.data.title == ""
assert nwGUI.theProject.data.authors == []
assert not nwGUI.theProject.spellCheck
assert nwGUI.theProject.data.spellCheck is False
# Check the files
projFile = os.path.join(fncProj, "nwProject.nwx")
@@ -197,7 +197,7 @@ def testGuiMain_Editing(qtbot, monkeypatch, nwGUI, fncProj, refDir, outDir, mock
assert nwGUI.theProject.data.name == "New Project"
assert nwGUI.theProject.data.title == "New Novel"
assert nwGUI.theProject.data.authors == ["Jane Doe"]
assert nwGUI.theProject.spellCheck is False
assert nwGUI.theProject.data.spellCheck is False
# Check that tree items have been created
assert nwGUI.projView.projTree._getTreeItem(C.hNovelRoot) is not None