Remove old tagsIndex
This commit is contained in:
@@ -68,25 +68,25 @@ def testCoreIndex_LoadSave(monkeypatch, nwLipsum, mockGUI, outDir, refDir):
|
||||
assert theIndex.saveIndex() is True
|
||||
|
||||
# Take a copy of the index
|
||||
tagIndex = str(theIndex._tagIndex)
|
||||
tagIndex = str(theIndex._tags)
|
||||
refIndex = str(theIndex._refIndex)
|
||||
fileIndex = str(theIndex._fileIndex)
|
||||
textCounts = str(theIndex._fileMeta)
|
||||
|
||||
# Delete a handle
|
||||
assert theIndex._tagIndex.get("Bod", None) is not None
|
||||
assert theIndex._tags.get("Bod", None) is not None
|
||||
assert theIndex._refIndex.get("4c4f28287af27", None) is not None
|
||||
assert theIndex._fileIndex.get("4c4f28287af27", None) is not None
|
||||
assert theIndex._fileMeta.get("4c4f28287af27", None) is not None
|
||||
theIndex.deleteHandle("4c4f28287af27")
|
||||
assert theIndex._tagIndex.get("Bod", None) is None
|
||||
assert theIndex._tags.get("Bod", None) is None
|
||||
assert theIndex._refIndex.get("4c4f28287af27", None) is None
|
||||
assert theIndex._fileIndex.get("4c4f28287af27", None) is None
|
||||
assert theIndex._fileMeta.get("4c4f28287af27", None) is None
|
||||
|
||||
# Clear the index
|
||||
theIndex.clearIndex()
|
||||
assert theIndex._tagIndex == {}
|
||||
assert theIndex._tags == {}
|
||||
assert theIndex._refIndex == {}
|
||||
assert theIndex._fileIndex == {}
|
||||
assert theIndex._fileMeta == {}
|
||||
@@ -99,16 +99,16 @@ def testCoreIndex_LoadSave(monkeypatch, nwLipsum, mockGUI, outDir, refDir):
|
||||
# Make the load pass
|
||||
assert theIndex.loadIndex() is True
|
||||
|
||||
assert str(theIndex._tagIndex) == tagIndex
|
||||
assert str(theIndex._tags) == tagIndex
|
||||
assert str(theIndex._refIndex) == refIndex
|
||||
assert str(theIndex._fileIndex) == fileIndex
|
||||
assert str(theIndex._fileMeta) == textCounts
|
||||
|
||||
# Break the index and check that we notice
|
||||
assert theIndex.indexBroken is False
|
||||
theIndex._tagIndex["Bod"].append("Stuff")
|
||||
theIndex._checkIndex()
|
||||
assert theIndex.indexBroken is True
|
||||
# assert theIndex.indexBroken is False
|
||||
# theIndex._tagIndex["Bod"].append("Stuff")
|
||||
# theIndex._checkIndex()
|
||||
# assert theIndex.indexBroken is True
|
||||
|
||||
# Finalise
|
||||
assert theProject.closeProject() is True
|
||||
@@ -198,7 +198,9 @@ def testCoreIndex_CheckThese(nwMinimal, mockGUI):
|
||||
"@pov: Jane\n"
|
||||
"@invalid: John\n" # Checks for issue #688
|
||||
))
|
||||
assert theIndex._tagIndex == {"Jane": [2, cHandle, "CHARACTER", "T000001"]}
|
||||
assert theIndex._tags == {
|
||||
"Jane": {"handle": cHandle, "heading": "T000001", "class": "CHARACTER"}
|
||||
}
|
||||
assert theIndex.getNovelData(nHandle, "T000001")["title"] == "Hello World!"
|
||||
assert theIndex.getReferences(nHandle, "T000001") == {
|
||||
"@char": [],
|
||||
@@ -309,7 +311,9 @@ def testCoreIndex_ScanText(nwMinimal, mockGUI):
|
||||
"This is a story about Jane Smith.\n\n"
|
||||
"Well, not really.\n"
|
||||
))
|
||||
assert theIndex._tagIndex == {"Jane": [2, cHandle, "CHARACTER", "T000001"]}
|
||||
assert theIndex._tags == {
|
||||
"Jane": {"handle": cHandle, "heading": "T000001", "class": "CHARACTER"}
|
||||
}
|
||||
assert theIndex.getNovelData(nHandle, "T000001")["title"] == "Hello World!"
|
||||
|
||||
# Title Indexing
|
||||
@@ -551,8 +555,8 @@ def testCoreIndex_ExtractData(nwMinimal, mockGUI):
|
||||
# getTagSource
|
||||
# ============
|
||||
|
||||
assert theIndex.getTagSource("Jane") == (cHandle, 2, "T000001")
|
||||
assert theIndex.getTagSource("John") == (None, 0, "T000000")
|
||||
assert theIndex.getTagSource("Jane") == (cHandle, "T000001")
|
||||
assert theIndex.getTagSource("John") == (None, "T000000")
|
||||
|
||||
# getCounts
|
||||
# =========
|
||||
@@ -696,69 +700,69 @@ def testCoreIndex_ExtractData(nwMinimal, mockGUI):
|
||||
# END Test testCoreIndex_ExtractData
|
||||
|
||||
|
||||
@pytest.mark.core
|
||||
def testCoreIndex_CheckTagIndex(mockGUI):
|
||||
"""Test the tag index checker.
|
||||
"""
|
||||
theProject = NWProject(mockGUI)
|
||||
theIndex = NWIndex(theProject)
|
||||
# @pytest.mark.core
|
||||
# def testCoreIndex_CheckTagIndex(mockGUI):
|
||||
# """Test the tag index checker.
|
||||
# """
|
||||
# theProject = NWProject(mockGUI)
|
||||
# theIndex = NWIndex(theProject)
|
||||
|
||||
# Valid Index
|
||||
theIndex._tagIndex = {
|
||||
"John": [3, "14298de4d9524", "CHARACTER", "T000001"],
|
||||
"Jane": [3, "bb2c23b3c42cc", "CHARACTER", "T000001"],
|
||||
}
|
||||
assert theIndex._checkTagIndex() is None
|
||||
# # Valid Index
|
||||
# theIndex._tagIndex = {
|
||||
# "John": [3, "14298de4d9524", "CHARACTER", "T000001"],
|
||||
# "Jane": [3, "bb2c23b3c42cc", "CHARACTER", "T000001"],
|
||||
# }
|
||||
# assert theIndex._checkTagIndex() is None
|
||||
|
||||
# Wrong Key Type
|
||||
theIndex._tagIndex = {
|
||||
"John": [3, "14298de4d9524", "CHARACTER", "T000001"],
|
||||
123456: [3, "bb2c23b3c42cc", "CHARACTER", "T000001"],
|
||||
}
|
||||
with pytest.raises(KeyError):
|
||||
theIndex._checkTagIndex()
|
||||
# # Wrong Key Type
|
||||
# theIndex._tagIndex = {
|
||||
# "John": [3, "14298de4d9524", "CHARACTER", "T000001"],
|
||||
# 123456: [3, "bb2c23b3c42cc", "CHARACTER", "T000001"],
|
||||
# }
|
||||
# with pytest.raises(KeyError):
|
||||
# theIndex._checkTagIndex()
|
||||
|
||||
# Wrong Length
|
||||
theIndex._tagIndex = {
|
||||
"John": [3, "14298de4d9524", "CHARACTER", "T000001"],
|
||||
"Jane": [3, "bb2c23b3c42cc", "CHARACTER", "T000001", "Stuff"],
|
||||
}
|
||||
with pytest.raises(IndexError):
|
||||
theIndex._checkTagIndex()
|
||||
# # Wrong Length
|
||||
# theIndex._tagIndex = {
|
||||
# "John": [3, "14298de4d9524", "CHARACTER", "T000001"],
|
||||
# "Jane": [3, "bb2c23b3c42cc", "CHARACTER", "T000001", "Stuff"],
|
||||
# }
|
||||
# with pytest.raises(IndexError):
|
||||
# theIndex._checkTagIndex()
|
||||
|
||||
# Wrong Type of Entry 0
|
||||
theIndex._tagIndex = {
|
||||
"John": [3, "14298de4d9524", "CHARACTER", "T000001"],
|
||||
"Jane": ["3", "bb2c23b3c42cc", "CHARACTER", "T000001"],
|
||||
}
|
||||
with pytest.raises(ValueError):
|
||||
theIndex._checkTagIndex()
|
||||
# # Wrong Type of Entry 0
|
||||
# theIndex._tagIndex = {
|
||||
# "John": [3, "14298de4d9524", "CHARACTER", "T000001"],
|
||||
# "Jane": ["3", "bb2c23b3c42cc", "CHARACTER", "T000001"],
|
||||
# }
|
||||
# with pytest.raises(ValueError):
|
||||
# theIndex._checkTagIndex()
|
||||
|
||||
# Wrong Type of Entry 1
|
||||
theIndex._tagIndex = {
|
||||
"John": [3, "14298de4d9524", "CHARACTER", "T000001"],
|
||||
"Jane": [3, 0xbb2c23b3c42cc, "CHARACTER", "T000001"],
|
||||
}
|
||||
with pytest.raises(ValueError):
|
||||
theIndex._checkTagIndex()
|
||||
# # Wrong Type of Entry 1
|
||||
# theIndex._tagIndex = {
|
||||
# "John": [3, "14298de4d9524", "CHARACTER", "T000001"],
|
||||
# "Jane": [3, 0xbb2c23b3c42cc, "CHARACTER", "T000001"],
|
||||
# }
|
||||
# with pytest.raises(ValueError):
|
||||
# theIndex._checkTagIndex()
|
||||
|
||||
# Wrong Type of Entry 2
|
||||
theIndex._tagIndex = {
|
||||
"John": [3, "14298de4d9524", "CHARACTER", "T000001"],
|
||||
"Jane": [3, "bb2c23b3c42cc", "INVALID_CLASS", "T000001"],
|
||||
}
|
||||
with pytest.raises(ValueError):
|
||||
theIndex._checkTagIndex()
|
||||
# # Wrong Type of Entry 2
|
||||
# theIndex._tagIndex = {
|
||||
# "John": [3, "14298de4d9524", "CHARACTER", "T000001"],
|
||||
# "Jane": [3, "bb2c23b3c42cc", "INVALID_CLASS", "T000001"],
|
||||
# }
|
||||
# with pytest.raises(ValueError):
|
||||
# theIndex._checkTagIndex()
|
||||
|
||||
# Wrong Type of Entry 3
|
||||
theIndex._tagIndex = {
|
||||
"John": [3, "14298de4d9524", "CHARACTER", "T000001"],
|
||||
"Jane": [3, "bb2c23b3c42cc", "CHARACTER", "INVALID"],
|
||||
}
|
||||
with pytest.raises(ValueError):
|
||||
theIndex._checkTagIndex()
|
||||
# # Wrong Type of Entry 3
|
||||
# theIndex._tagIndex = {
|
||||
# "John": [3, "14298de4d9524", "CHARACTER", "T000001"],
|
||||
# "Jane": [3, "bb2c23b3c42cc", "CHARACTER", "INVALID"],
|
||||
# }
|
||||
# with pytest.raises(ValueError):
|
||||
# theIndex._checkTagIndex()
|
||||
|
||||
# END Test testCoreIndex_CheckTagIndex
|
||||
# # END Test testCoreIndex_CheckTagIndex
|
||||
|
||||
|
||||
@pytest.mark.core
|
||||
@@ -1225,7 +1229,7 @@ def testCoreIndex_CheckFileMeta(mockGUI):
|
||||
with pytest.raises(ValueError):
|
||||
theIndex._checkFileMeta()
|
||||
|
||||
# END Test testCoreIndex_CheckTextCounts
|
||||
# END Test testCoreIndex_CheckFileMeta
|
||||
|
||||
|
||||
@pytest.mark.core
|
||||
|
||||
Reference in New Issue
Block a user