From b9d344c7d98fca1b255283b69d9268eb39dc472a Mon Sep 17 00:00:00 2001 From: "Veronica K. B. Olsen" <1619840+vkbo@users.noreply.github.com> Date: Tue, 23 Feb 2021 22:07:14 +0100 Subject: [PATCH] Make sure the test cheks for issue 688 --- nw/core/index.py | 2 +- tests/test_core/test_core_index.py | 18 +++++++++++++++--- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/nw/core/index.py b/nw/core/index.py index 36c27b27..a291c22e 100644 --- a/nw/core/index.py +++ b/nw/core/index.py @@ -717,7 +717,7 @@ class NWIndex(): for refTitle in self._refIndex[tHandle]: for aTag in self._refIndex[tHandle][refTitle].get("tags", []): if len(aTag) == 3 and (sTitle is None or sTitle == refTitle): - if aTag[1] in theRefs: # Future-compatible. Check can be removed in 1.2. + if aTag[1] in theRefs: theRefs[aTag[1]].append(aTag[2]) return theRefs diff --git a/tests/test_core/test_core_index.py b/tests/test_core/test_core_index.py index 9b1c656a..991f3215 100644 --- a/tests/test_core/test_core_index.py +++ b/tests/test_core/test_core_index.py @@ -198,14 +198,26 @@ def testCoreIndex_CheckThese(nwMinimal, dummyGUI): assert theIndex.scanText(cHandle, ( "# Jane Smith\n" - "@tag: Jane" + "@tag: Jane\n" )) assert theIndex.scanText(nHandle, ( "# Hello World!\n" - "@pov: Jane" + "@pov: Jane\n" + "@invalid: John\n" # Checks for issue #688 )) assert theIndex._tagIndex == {"Jane": [2, cHandle, "CHARACTER", "T000001"]} assert theIndex.getNovelData(nHandle, "T000001")["title"] == "Hello World!" + assert theIndex.getReferences(nHandle, "T000001") == { + "@char": [], + "@custom": [], + "@entity": [], + "@focus": [], + "@location": [], + "@object": [], + "@plot": [], + "@pov": ["Jane"], + "@time": [] + } assert theIndex.novelChangedSince(0) assert theIndex.notesChangedSince(0) @@ -281,7 +293,7 @@ def testCoreIndex_ScanText(nwMinimal, dummyGUI): "This is a story about Jane Smith.\n\n" "Well, not really.\n" )) - assert str(theIndex._tagIndex) == "{'Jane': [2, '%s', 'CHARACTER', 'T000001']}" % cHandle + assert theIndex._tagIndex == {"Jane": [2, cHandle, "CHARACTER", "T000001"]} assert theIndex.getNovelData(nHandle, "T000001")["title"] == "Hello World!" # Check that title sections are indexed properly