Test terminology update

This commit is contained in:
Veronica K. B. Olsen
2021-05-02 17:48:28 +02:00
parent 7867965989
commit 6c79a1daba
23 changed files with 92 additions and 92 deletions
+3 -3
View File
@@ -23,7 +23,7 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
import os
import pytest
from dummy import causeOSError
from mock import causeOSError
from nw.core import NWProject, NWDoc
from nw.enum import nwItemClass, nwItemLayout
@@ -39,7 +39,7 @@ def testCoreDocument_LoadSave(monkeypatch, dummyGUI, nwMinimal):
sHandle = "8c659a11cd429"
# Not a valid handle
theDoc = NWDoc(theProject, "dummy")
theDoc = NWDoc(theProject, "stuff")
assert theDoc.readDocument() is None
# Non-existent handle
@@ -102,7 +102,7 @@ def testCoreDocument_LoadSave(monkeypatch, dummyGUI, nwMinimal):
assert not theDoc.writeDocument(theText)
# Delete the last document
theDoc = NWDoc(theProject, "dummy")
theDoc = NWDoc(theProject, "stuff")
assert not theDoc.deleteDocument()
assert os.path.isfile(docPath)
+1 -1
View File
@@ -26,7 +26,7 @@ import json
from shutil import copyfile
from dummy import causeException
from mock import causeException
from tools import cmpFiles
from nw.core.project import NWProject
+1 -1
View File
@@ -24,7 +24,7 @@ import os
import json
import pytest
from dummy import causeOSError
from mock import causeOSError
from nw.core import NWProject
from nw.core.options import OptionState
+18 -18
View File
@@ -28,7 +28,7 @@ from zipfile import ZipFile
from lxml import etree
from tools import cmpFiles, writeFile, readFile
from dummy import causeOSError
from mock import causeOSError
from nw.core.project import NWProject
from nw.enum import nwItemClass, nwItemType, nwItemLayout
@@ -354,11 +354,11 @@ def testCoreProject_Open(monkeypatch, nwMinimal, dummyGUI):
oName = os.path.join(nwMinimal, nwFiles.PROJ_FILE[:-3]+"orig")
bName = os.path.join(nwMinimal, nwFiles.PROJ_FILE[:-3]+"bak")
os.rename(rName, oName)
writeFile(rName, "dummy")
writeFile(rName, "stuff")
assert theProject.openProject(nwMinimal) is False
# Also write a jun XML backup file
writeFile(bName, "dummy")
writeFile(bName, "stuff")
assert theProject.openProject(nwMinimal) is False
# Wrong root item
@@ -426,9 +426,9 @@ def testCoreProject_Open(monkeypatch, nwMinimal, dummyGUI):
os.rename(oName, rName)
# Add some legacy stuff that cannot be removed
writeFile(os.path.join(nwMinimal, "junk"), "dummy")
writeFile(os.path.join(nwMinimal, "junk"), "stuff")
os.mkdir(os.path.join(nwMinimal, "data_0"))
writeFile(os.path.join(nwMinimal, "data_0", "junk"), "dummy")
writeFile(os.path.join(nwMinimal, "data_0", "junk"), "stuff")
dummyGUI.clear()
assert theProject.openProject(nwMinimal) is True
assert "data_0" in dummyGUI.lastAlert
@@ -559,19 +559,19 @@ def testCoreProject_Helpers(monkeypatch, fncDir, dummyGUI):
# Create a file to block meta folder
metaDir = os.path.join(fncDir, "meta")
writeFile(metaDir, "dummy")
writeFile(metaDir, "stuff")
assert theProject.ensureFolderStructure() is False
os.unlink(metaDir)
# Create a file to block cache folder
cacheDir = os.path.join(fncDir, "cache")
writeFile(cacheDir, "dummy")
writeFile(cacheDir, "stuff")
assert theProject.ensureFolderStructure() is False
os.unlink(cacheDir)
# Create a file to block content folder
contentDir = os.path.join(fncDir, "content")
writeFile(contentDir, "dummy")
writeFile(contentDir, "stuff")
assert theProject.ensureFolderStructure() is False
os.unlink(contentDir)
@@ -977,7 +977,7 @@ def testCoreProject_OldFormat(dummyGUI, nwOldProj):
"""
theProject = NWProject(dummyGUI)
# Create dummy files for known legacy files
# Create mock files for known legacy files
deleteFiles = [
os.path.join(nwOldProj, "cache", "nwProject.nwx.0"),
os.path.join(nwOldProj, "cache", "nwProject.nwx.1"),
@@ -1005,7 +1005,7 @@ def testCoreProject_OldFormat(dummyGUI, nwOldProj):
os.mkdir(os.path.join(nwOldProj, "stuff"))
os.mkdir(os.path.join(nwOldProj, "data_1", "stuff"))
# Create dummy files
# Create mock files
os.mkdir(os.path.join(nwOldProj, "cache"))
for aFile in deleteFiles:
writeFile(aFile, "Hi")
@@ -1071,7 +1071,7 @@ def testCoreProject_LegacyData(monkeypatch, dummyGUI, fncDir):
# Check behaviour of deprecated files function on OSError
tstFile = os.path.join(fncDir, "ToC.json")
writeFile(tstFile, "dummy")
writeFile(tstFile, "stuff")
assert os.path.isfile(tstFile)
with monkeypatch.context() as mp:
@@ -1083,7 +1083,7 @@ def testCoreProject_LegacyData(monkeypatch, dummyGUI, fncDir):
# Check processing non-folders
tstFile = os.path.join(fncDir, "data_0")
writeFile(tstFile, "dummy")
writeFile(tstFile, "stuff")
assert os.path.isfile(tstFile)
errList = []
@@ -1128,12 +1128,12 @@ def testCoreProject_LegacyData(monkeypatch, dummyGUI, fncDir):
tstDoc3b = os.path.join(tstData, "tooshort003_main.bak")
os.mkdir(tstData)
writeFile(tstDoc1m, "dummy")
writeFile(tstDoc1b, "dummy")
writeFile(tstDoc2m, "dummy")
writeFile(tstDoc2b, "dummy")
writeFile(tstDoc3m, "dummy")
writeFile(tstDoc3b, "dummy")
writeFile(tstDoc1m, "stuff")
writeFile(tstDoc1b, "stuff")
writeFile(tstDoc2m, "stuff")
writeFile(tstDoc2b, "stuff")
writeFile(tstDoc3m, "stuff")
writeFile(tstDoc3b, "stuff")
# Make the above fail
with monkeypatch.context() as mp:
+4 -4
View File
@@ -24,7 +24,7 @@ import os
import sys
import pytest
from dummy import causeOSError
from mock import causeOSError
from tools import readFile, writeFile
from nw.core.spellcheck import NWSpellCheck, NWSpellEnchant, NWSpellSimple
@@ -38,7 +38,7 @@ def testCoreSpell_Super(monkeypatch, tmpDir):
spChk = NWSpellCheck()
# Check that dummy functions return results that reflects that spell
# Check that default functions return results that reflects that spell
# checking is effectively disabled
assert spChk.setLanguage("", "") is None
assert spChk.checkWord("")
@@ -47,7 +47,7 @@ def testCoreSpell_Super(monkeypatch, tmpDir):
assert spChk.describeDict() == ("", "")
# Add a word to the user's dictionary
assert spChk._readProjectDictionary("dummy") is False
assert spChk._readProjectDictionary("stuff") is False
with monkeypatch.context() as mp:
mp.setattr("builtins.open", causeOSError)
assert spChk._readProjectDictionary(wList) is False
@@ -77,7 +77,7 @@ def testCoreSpell_Enchant(monkeypatch, tmpDir):
wList = os.path.join(tmpDir, "wordlist.txt")
writeFile(wList, "a_word\nb_word\nc_word\n")
# Block the enchant package (and trigger the dummy class)
# Block the enchant package (and trigger the default class)
with monkeypatch.context() as mp:
mp.setitem(sys.modules, "enchant", None)
spChk = NWSpellEnchant()
+1 -1
View File
@@ -49,7 +49,7 @@ def testCoreStatus_Entries():
# Lookups
assert theStatus.lookupEntry(None) is None
assert theStatus.lookupEntry("dummy") is None
assert theStatus.lookupEntry("stuff") is None
assert theStatus.lookupEntry("Main") == 3
# Checks
+2 -2
View File
@@ -145,13 +145,13 @@ def testCoreToken_TextOps(monkeypatch, nwMinimal, dummyGUI):
assert theProject.saveProject()
# Root heading
assert theToken.addRootHeading("dummy") is False
assert theToken.addRootHeading("stuff") is False
assert theToken.addRootHeading(sHandle) is False
assert theToken.addRootHeading("7695ce551d265") is True
assert theToken.theMarkdown[-1] == "# Notes: Plot\n\n"
# Set text
assert theToken.setText("dummy") is False
assert theToken.setText("stuff") is False
assert theToken.setText(sHandle) is True
assert theToken.theText == docText
+11 -11
View File
@@ -31,7 +31,7 @@ from nw.constants import nwFiles
@pytest.fixture(scope="function")
def dummyItems(dummyGUI):
"""Create a list of dummy items.
"""Create a list of mock items.
"""
theProject = NWProject(dummyGUI)
@@ -176,7 +176,7 @@ def testCoreTree_BuildTree(dummyGUI, dummyItems):
assert len(theTree) == len(dummyItems) + 1
# Delete a non-existing item
del theTree["dummy"]
del theTree["stuff"]
assert len(theTree) == len(dummyItems) + 1
# Delete the last item
@@ -214,7 +214,7 @@ def testCoreTree_Methods(dummyGUI, dummyItems):
assert len(theTree) == len(dummyItems)
# Root item lookup
theTree._treeRoots.append("dummy")
theTree._treeRoots.append("stuff")
assert theTree.findRoot(nwItemClass.WORLD) is None
assert theTree.findRoot(nwItemClass.NOVEL) == "a000000000001"
assert theTree.findRoot(nwItemClass.CHARACTER) == "a000000000004"
@@ -229,16 +229,16 @@ def testCoreTree_Methods(dummyGUI, dummyItems):
assert theTree.getRootItem("b000000000001").itemHandle == "a000000000001"
assert theTree.getRootItem("c000000000001").itemHandle == "a000000000001"
assert theTree.getRootItem("c000000000002").itemHandle == "a000000000001"
assert theTree.getRootItem("dummy") is None
assert theTree.getRootItem("stuff") is None
# Get item path
assert theTree.getItemPath("dummy") == []
assert theTree.getItemPath("stuff") == []
assert theTree.getItemPath("c000000000001") == [
"c000000000001", "b000000000001", "a000000000001"
]
# Break the folder parent handle
theTree["b000000000001"].itemParent = "dummy"
theTree["b000000000001"].itemParent = "stuff"
assert theTree.getItemPath("c000000000001") == [
"c000000000001", "b000000000001"
]
@@ -249,7 +249,7 @@ def testCoreTree_Methods(dummyGUI, dummyItems):
]
# Change file layout
assert not theTree.setFileItemLayout("dummy", nwItemLayout.UNNUMBERED)
assert not theTree.setFileItemLayout("stuff", nwItemLayout.UNNUMBERED)
assert not theTree.setFileItemLayout("b000000000001", nwItemLayout.UNNUMBERED)
assert not theTree.setFileItemLayout("c000000000001", "stuff")
assert theTree.setFileItemLayout("c000000000001", nwItemLayout.UNNUMBERED)
@@ -424,7 +424,7 @@ def testCoreTree_Stats(dummyGUI, dummyItems):
theTree.append(tHandle, pHandle, nwItem)
assert len(theTree) == len(dummyItems)
theTree._treeOrder.append("dummy")
theTree._treeOrder.append("stuff")
# Count Words
novelWords, noteWords = theTree.sumWords()
@@ -461,10 +461,10 @@ def testCoreTree_Reorder(dummyGUI, dummyItems):
theTree.setOrder(bHandle)
assert theTree.handles() == bHandle
theTree.setOrder(bHandle + ["dummy"])
theTree.setOrder(bHandle + ["stuff"])
assert theTree.handles() == bHandle
theTree._treeOrder.append("dummy")
theTree._treeOrder.append("stuff")
theTree.setOrder(bHandle)
assert theTree.handles() == bHandle
@@ -536,7 +536,7 @@ def testCoreTree_ToCFile(monkeypatch, dummyGUI, dummyItems, tmpDir):
theTree.append(tHandle, pHandle, nwItem)
assert len(theTree) == len(dummyItems)
theTree._treeOrder.append("dummy")
theTree._treeOrder.append("stuff")
def dummyIsFile(fileName):
"""Return True for items that are files in novelWriter and