Remove titleFormat from project XML and rename mock test file
This commit is contained in:
@@ -170,11 +170,6 @@ class NWProjectData:
|
||||
"""Return the autoreplace dictionary."""
|
||||
return self._autoReplace
|
||||
|
||||
@property
|
||||
def titleFormat(self):
|
||||
"""Delete"""
|
||||
return self._titleFormat
|
||||
|
||||
@property
|
||||
def itemStatus(self) -> NWStatus:
|
||||
"""Return the status settings object."""
|
||||
@@ -209,10 +204,6 @@ class NWProjectData:
|
||||
"""Retrieve the last used handle for a given component."""
|
||||
return self._lastHandle.get(component, None)
|
||||
|
||||
def getTitleFormat(self, kind):
|
||||
"""Retrieve the title format string for a given kind of header."""
|
||||
return self._titleFormat.get(kind, "%title%")
|
||||
|
||||
##
|
||||
# Setters
|
||||
##
|
||||
@@ -337,13 +328,4 @@ class NWProjectData:
|
||||
self.theProject.setProjectChanged(True)
|
||||
return
|
||||
|
||||
def setTitleFormat(self, value):
|
||||
"""Set the title formats."""
|
||||
if isinstance(value, dict):
|
||||
for key, entry in value.items():
|
||||
if key in self._titleFormat and isinstance(entry, str):
|
||||
self._titleFormat[key] = simplified(entry)
|
||||
self.theProject.setProjectChanged(True)
|
||||
return
|
||||
|
||||
# END Class NWProjectData
|
||||
|
||||
@@ -280,11 +280,6 @@ class ProjectXMLReader:
|
||||
data.setAutoReplace(self._parseDictKeyText(xItem))
|
||||
else: # Pre 1.2 format
|
||||
data.setAutoReplace(self._parseDictTagText(xItem))
|
||||
elif xItem.tag == "titleFormat":
|
||||
if self._version >= 0x0105:
|
||||
data.setTitleFormat(self._parseDictKeyText(xItem))
|
||||
else: # Pre 1.4 format
|
||||
data.setTitleFormat(self._parseDictTagText(xItem))
|
||||
else:
|
||||
logger.warning("Ignored <root/settings/%s> in XML", xItem.tag)
|
||||
|
||||
@@ -523,7 +518,6 @@ class ProjectXMLWriter:
|
||||
})
|
||||
self._packDictKeyValue(xSettings, "lastHandle", data.lastHandle)
|
||||
self._packDictKeyValue(xSettings, "autoReplace", data.autoReplace)
|
||||
self._packDictKeyValue(xSettings, "titleFormat", data.titleFormat)
|
||||
|
||||
# Save Status/Importance
|
||||
xStatus = ET.SubElement(xSettings, "status")
|
||||
|
||||
+1
-1
@@ -25,7 +25,7 @@ import shutil
|
||||
|
||||
from pathlib import Path
|
||||
|
||||
from mock import MockGuiMain
|
||||
from mocked import MockGuiMain
|
||||
from tools import cleanProject
|
||||
|
||||
from PyQt5.QtWidgets import QMessageBox
|
||||
|
||||
@@ -25,7 +25,7 @@ import hashlib
|
||||
|
||||
from pathlib import Path
|
||||
|
||||
from mock import causeOSError
|
||||
from mocked import causeOSError
|
||||
from tools import writeFile
|
||||
|
||||
from novelwriter.guimain import GuiMain
|
||||
|
||||
@@ -25,7 +25,7 @@ import pytest
|
||||
from shutil import copyfile
|
||||
from pathlib import Path
|
||||
|
||||
from mock import causeOSError, MockApp
|
||||
from mocked import causeOSError, MockApp
|
||||
from tools import cmpFiles, writeFile
|
||||
|
||||
from novelwriter import CONFIG
|
||||
|
||||
@@ -21,7 +21,7 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
import pytest
|
||||
|
||||
from mock import causeException
|
||||
from mocked import causeException
|
||||
|
||||
from novelwriter.error import NWErrorMessage, exceptionHandler
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@ import sys
|
||||
import pytest
|
||||
import logging
|
||||
|
||||
from mock import MockGuiMain
|
||||
from mocked import MockGuiMain
|
||||
|
||||
from novelwriter import CONFIG, main, logger
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@ import pytest
|
||||
from shutil import copyfile
|
||||
from zipfile import ZipFile
|
||||
|
||||
from mock import causeOSError
|
||||
from mocked import causeOSError
|
||||
from tools import C, buildTestProject, cmpFiles, XML_IGNORE
|
||||
|
||||
from novelwriter import CONFIG
|
||||
|
||||
@@ -23,7 +23,7 @@ import pytest
|
||||
|
||||
from shutil import copyfile
|
||||
|
||||
from mock import causeException, causeOSError
|
||||
from mocked import causeException, causeOSError
|
||||
from novelwriter.core.buildsettings import BuildSettings
|
||||
from tools import ODT_IGNORE, cmpFiles
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
import pytest
|
||||
|
||||
from mock import causeOSError
|
||||
from mocked import causeOSError
|
||||
from tools import C, buildTestProject, readFile, writeFile
|
||||
|
||||
from novelwriter.enum import nwItemClass, nwItemLayout
|
||||
|
||||
@@ -24,7 +24,7 @@ import pytest
|
||||
|
||||
from shutil import copyfile
|
||||
|
||||
from mock import causeException
|
||||
from mocked import causeException
|
||||
from tools import C, buildTestProject, cmpFiles, writeFile
|
||||
|
||||
from novelwriter.enum import nwItemClass, nwItemLayout
|
||||
|
||||
@@ -22,7 +22,7 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
import json
|
||||
import pytest
|
||||
|
||||
from mock import causeOSError
|
||||
from mocked import causeOSError
|
||||
|
||||
from novelwriter.constants import nwFiles
|
||||
from novelwriter.core.options import OptionState
|
||||
|
||||
@@ -26,7 +26,7 @@ from shutil import copyfile
|
||||
from pathlib import Path
|
||||
from zipfile import ZipFile
|
||||
|
||||
from mock import causeOSError
|
||||
from mocked import causeOSError
|
||||
from tools import C, cmpFiles, writeFile, buildTestProject, XML_IGNORE
|
||||
|
||||
from novelwriter import CONFIG
|
||||
|
||||
@@ -25,8 +25,8 @@ import pytest
|
||||
from shutil import copyfile
|
||||
from datetime import datetime
|
||||
|
||||
from mock import causeOSError
|
||||
from tools import cmpFiles, writeFile
|
||||
from mocked import causeOSError
|
||||
|
||||
from novelwriter.core.item import NWItem
|
||||
from novelwriter.core.projectxml import ProjectXMLReader, ProjectXMLWriter, XMLReadState
|
||||
@@ -34,12 +34,16 @@ from novelwriter.core.projectdata import NWProjectData
|
||||
|
||||
|
||||
class MockProject:
|
||||
"""Fake project object."""
|
||||
|
||||
def setProjectChanged(self, *a):
|
||||
"""Fake project method."""
|
||||
pass
|
||||
|
||||
|
||||
@pytest.fixture(scope="function", autouse=True)
|
||||
def mockVersion(monkeypatch):
|
||||
"""Mock the version info to prevent diff from failing."""
|
||||
monkeypatch.setattr("novelwriter.core.projectxml.__version__", "2.0-rc1")
|
||||
monkeypatch.setattr("novelwriter.core.projectxml.__hexversion__", "0x020000c1")
|
||||
return
|
||||
@@ -47,8 +51,7 @@ def mockVersion(monkeypatch):
|
||||
|
||||
@pytest.mark.core
|
||||
def testCoreProjectXML_ReadCurrent(monkeypatch, tstPaths, fncPath):
|
||||
"""Test reading the current XML file format.
|
||||
"""
|
||||
"""Test reading the current XML file format."""
|
||||
refFile = tstPaths.filesDir / "nwProject-1.5.nwx"
|
||||
tstFile = tstPaths.outDir / "ProjectXML_ReadCurrent.nwx"
|
||||
xmlFile = fncPath / "nwProject-1.5.nwx"
|
||||
@@ -160,12 +163,6 @@ def testCoreProjectXML_ReadCurrent(monkeypatch, tstPaths, fncPath):
|
||||
assert data.getLastHandle("novelTree") == "7031beac91f75"
|
||||
assert data.getLastHandle("outline") == "7031beac91f75"
|
||||
|
||||
assert data.getTitleFormat("title") == "%title%"
|
||||
assert data.getTitleFormat("chapter") == "Chapter %chw%: %title%"
|
||||
assert data.getTitleFormat("unnumbered") == "%title%"
|
||||
assert data.getTitleFormat("scene") == "Scene %ch%.%sc%: %title%"
|
||||
assert data.getTitleFormat("section") == ""
|
||||
|
||||
assert data.itemStatus.name("sf12341") == "New"
|
||||
assert data.itemStatus.name("sf24ce6") == "Notes"
|
||||
assert data.itemStatus.name("sc24b8f") == "Started"
|
||||
@@ -286,12 +283,6 @@ def testCoreProjectXML_ReadLegacy10(tstPaths, fncPath, mockRnd):
|
||||
assert data.getLastHandle("novelTree") is None # Doesn't exist in 1.0
|
||||
assert data.getLastHandle("outline") is None # Doesn't exist in 1.0
|
||||
|
||||
assert data.getTitleFormat("title") == "%title%"
|
||||
assert data.getTitleFormat("chapter") == "Chapter %ch%: %title%"
|
||||
assert data.getTitleFormat("unnumbered") == "%title%"
|
||||
assert data.getTitleFormat("scene") == "Scene %ch%.%sc%: %title%"
|
||||
assert data.getTitleFormat("section") == ""
|
||||
|
||||
assert data.itemStatus.name("s000000") == "New"
|
||||
assert data.itemStatus.name("s000001") == "Notes"
|
||||
assert data.itemStatus.name("s000002") == "Started"
|
||||
@@ -388,8 +379,7 @@ def testCoreProjectXML_ReadLegacy10(tstPaths, fncPath, mockRnd):
|
||||
|
||||
@pytest.mark.core
|
||||
def testCoreProjectXML_ReadLegacy11(tstPaths, fncPath, mockRnd):
|
||||
"""Test reading the version 1.1 XML file format.
|
||||
"""
|
||||
"""Test reading the version 1.1 XML file format."""
|
||||
refFile = tstPaths.filesDir / "nwProject-1.1.nwx"
|
||||
xmlFile = fncPath / "nwProject-1.1.nwx"
|
||||
outFile = fncPath / "nwProject.nwx"
|
||||
@@ -428,12 +418,6 @@ def testCoreProjectXML_ReadLegacy11(tstPaths, fncPath, mockRnd):
|
||||
assert data.getLastHandle("novelTree") is None # Doesn't exist in 1.1
|
||||
assert data.getLastHandle("outline") is None # Doesn't exist in 1.1
|
||||
|
||||
assert data.getTitleFormat("title") == "%title%"
|
||||
assert data.getTitleFormat("chapter") == "Chapter %ch%: %title%"
|
||||
assert data.getTitleFormat("unnumbered") == "%title%"
|
||||
assert data.getTitleFormat("scene") == "Scene %ch%.%sc%: %title%"
|
||||
assert data.getTitleFormat("section") == ""
|
||||
|
||||
assert data.itemStatus.name("s000000") == "New"
|
||||
assert data.itemStatus.name("s000001") == "Notes"
|
||||
assert data.itemStatus.name("s000002") == "Started"
|
||||
@@ -530,8 +514,7 @@ def testCoreProjectXML_ReadLegacy11(tstPaths, fncPath, mockRnd):
|
||||
|
||||
@pytest.mark.core
|
||||
def testCoreProjectXML_ReadLegacy12(tstPaths, fncPath, mockRnd):
|
||||
"""Test reading the version 1.2 XML file format.
|
||||
"""
|
||||
"""Test reading the version 1.2 XML file format."""
|
||||
refFile = tstPaths.filesDir / "nwProject-1.2.nwx"
|
||||
xmlFile = fncPath / "nwProject-1.2.nwx"
|
||||
outFile = fncPath / "nwProject.nwx"
|
||||
@@ -570,12 +553,6 @@ def testCoreProjectXML_ReadLegacy12(tstPaths, fncPath, mockRnd):
|
||||
assert data.getLastHandle("novelTree") is None # Doesn't exist in 1.2
|
||||
assert data.getLastHandle("outline") is None # Doesn't exist in 1.2
|
||||
|
||||
assert data.getTitleFormat("title") == "%title%"
|
||||
assert data.getTitleFormat("chapter") == "Chapter %chw%: %title%"
|
||||
assert data.getTitleFormat("unnumbered") == "%title%"
|
||||
assert data.getTitleFormat("scene") == "Scene %ch%.%sc%: %title%"
|
||||
assert data.getTitleFormat("section") == ""
|
||||
|
||||
assert data.itemStatus.name("s000000") == "New"
|
||||
assert data.itemStatus.name("s000001") == "Notes"
|
||||
assert data.itemStatus.name("s000002") == "Started"
|
||||
@@ -675,8 +652,7 @@ def testCoreProjectXML_ReadLegacy12(tstPaths, fncPath, mockRnd):
|
||||
|
||||
@pytest.mark.core
|
||||
def testCoreProjectXML_ReadLegacy13(tstPaths, fncPath, mockRnd):
|
||||
"""Test reading the version 1.3 XML file format.
|
||||
"""
|
||||
"""Test reading the version 1.3 XML file format."""
|
||||
refFile = tstPaths.filesDir / "nwProject-1.3.nwx"
|
||||
xmlFile = fncPath / "nwProject-1.3.nwx"
|
||||
outFile = fncPath / "nwProject.nwx"
|
||||
@@ -715,12 +691,6 @@ def testCoreProjectXML_ReadLegacy13(tstPaths, fncPath, mockRnd):
|
||||
assert data.getLastHandle("novelTree") is None # Doesn't exist in 1.3
|
||||
assert data.getLastHandle("outline") is None # Doesn't exist in 1.3
|
||||
|
||||
assert data.getTitleFormat("title") == "%title%"
|
||||
assert data.getTitleFormat("chapter") == "Chapter %chw%: %title%"
|
||||
assert data.getTitleFormat("unnumbered") == "%title%"
|
||||
assert data.getTitleFormat("scene") == "Scene %ch%.%sc%: %title%"
|
||||
assert data.getTitleFormat("section") == ""
|
||||
|
||||
assert data.itemStatus.name("s000000") == "New"
|
||||
assert data.itemStatus.name("s000001") == "Notes"
|
||||
assert data.itemStatus.name("s000002") == "Started"
|
||||
@@ -820,8 +790,7 @@ def testCoreProjectXML_ReadLegacy13(tstPaths, fncPath, mockRnd):
|
||||
|
||||
@pytest.mark.core
|
||||
def testCoreProjectXML_ReadLegacy14(tstPaths, fncPath, mockRnd):
|
||||
"""Test reading the version 1.4 XML file format.
|
||||
"""
|
||||
"""Test reading the version 1.4 XML file format."""
|
||||
refFile = tstPaths.filesDir / "nwProject-1.4.nwx"
|
||||
xmlFile = fncPath / "nwProject-1.4.nwx"
|
||||
outFile = fncPath / "nwProject.nwx"
|
||||
@@ -860,12 +829,6 @@ def testCoreProjectXML_ReadLegacy14(tstPaths, fncPath, mockRnd):
|
||||
assert data.getLastHandle("novelTree") is None # Doesn't exist in 1.3
|
||||
assert data.getLastHandle("outline") is None # Doesn't exist in 1.3
|
||||
|
||||
assert data.getTitleFormat("title") == "%title%"
|
||||
assert data.getTitleFormat("chapter") == "Chapter %chw%: %title%"
|
||||
assert data.getTitleFormat("unnumbered") == "%title%"
|
||||
assert data.getTitleFormat("scene") == "Scene %ch%.%sc%: %title%"
|
||||
assert data.getTitleFormat("section") == ""
|
||||
|
||||
assert data.itemStatus.name("sf12341") == "New"
|
||||
assert data.itemStatus.name("sf24ce6") == "Notes"
|
||||
assert data.itemStatus.name("sc24b8f") == "Started"
|
||||
|
||||
@@ -22,7 +22,7 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
import sys
|
||||
import pytest
|
||||
|
||||
from mock import causeOSError
|
||||
from mocked import causeOSError
|
||||
from tools import readFile, writeFile
|
||||
|
||||
from novelwriter.core.spellcheck import FakeEnchant, NWSpellEnchant
|
||||
|
||||
@@ -22,7 +22,7 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
from zipfile import ZipFile
|
||||
import pytest
|
||||
|
||||
from mock import causeOSError
|
||||
from mocked import causeOSError
|
||||
from tools import C, buildTestProject, writeFile
|
||||
|
||||
from novelwriter import CONFIG
|
||||
|
||||
@@ -24,7 +24,7 @@ import random
|
||||
|
||||
from pathlib import Path
|
||||
|
||||
from mock import causeOSError
|
||||
from mocked import causeOSError
|
||||
from tools import readFile
|
||||
|
||||
from novelwriter.enum import nwItemClass, nwItemType, nwItemLayout
|
||||
|
||||
@@ -25,7 +25,7 @@ from PyQt5.QtCore import Qt
|
||||
from PyQt5.QtWidgets import QDialog, QAction
|
||||
|
||||
from tools import buildTestProject, writeFile, readFile, getGuiItem
|
||||
from mock import causeOSError
|
||||
from mocked import causeOSError
|
||||
|
||||
from novelwriter.constants import nwFiles
|
||||
from novelwriter.dialogs.wordlist import GuiWordList
|
||||
|
||||
@@ -21,7 +21,7 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
import pytest
|
||||
|
||||
from mock import causeOSError
|
||||
from mocked import causeOSError
|
||||
from tools import C, buildTestProject
|
||||
|
||||
from PyQt5.QtCore import Qt
|
||||
|
||||
@@ -21,7 +21,7 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
import pytest
|
||||
|
||||
from mock import causeException
|
||||
from mocked import causeException
|
||||
|
||||
from PyQt5.QtCore import Qt, QUrl
|
||||
from PyQt5.QtGui import QTextCursor
|
||||
|
||||
@@ -21,7 +21,7 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
import pytest
|
||||
|
||||
from mock import causeOSError
|
||||
from mocked import causeOSError
|
||||
from tools import C, buildTestProject
|
||||
|
||||
from PyQt5.QtCore import Qt
|
||||
|
||||
@@ -24,7 +24,7 @@ import pytest
|
||||
from pathlib import Path
|
||||
from configparser import ConfigParser
|
||||
|
||||
from mock import causeOSError
|
||||
from mocked import causeOSError
|
||||
from tools import writeFile
|
||||
|
||||
from PyQt5.QtGui import QIcon, QPalette, QPixmap
|
||||
|
||||
@@ -22,7 +22,7 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
import json
|
||||
import pytest
|
||||
|
||||
from mock import causeOSError
|
||||
from mocked import causeOSError
|
||||
from tools import getGuiItem, writeFile, buildTestProject
|
||||
|
||||
from PyQt5.QtCore import Qt
|
||||
|
||||
Reference in New Issue
Block a user