From 7f8e2c66a63f8a5007a918d02c5b8471aefee773 Mon Sep 17 00:00:00 2001 From: Veronica Berglyd Olsen <1619840+vkbo@users.noreply.github.com> Date: Fri, 25 Oct 2024 00:13:09 +0200 Subject: [PATCH] Update tests --- tests/test_core/test_core_index.py | 32 +++++++++++++++++++++++++++++- tests/test_gui/test_gui_outline.py | 4 ++-- 2 files changed, 33 insertions(+), 3 deletions(-) diff --git a/tests/test_core/test_core_index.py b/tests/test_core/test_core_index.py index 176174bd..b02a3212 100644 --- a/tests/test_core/test_core_index.py +++ b/tests/test_core/test_core_index.py @@ -224,13 +224,17 @@ def testCoreIndex_CheckThese(mockGUI, fncPath, mockRnd): nHandle = project.newFile("Hello", C.hNovelRoot) cHandle = project.newFile("Jane", C.hCharRoot) + wHandle = project.newFile("Earth", C.hWorldRoot) assert isinstance(nHandle, str) assert isinstance(cHandle, str) + assert isinstance(wHandle, str) nItem = project.tree[nHandle] cItem = project.tree[cHandle] + wItem = project.tree[wHandle] assert isinstance(nItem, NWItem) assert isinstance(cItem, NWItem) + assert isinstance(wItem, NWItem) assert index.rootChangedSince(C.hNovelRoot, 0) is False assert index.rootChangedSince(None, 0) is False @@ -242,21 +246,31 @@ def testCoreIndex_CheckThese(mockGUI, fncPath, mockRnd): "@tag:\n" "@:\n" )) + assert index.scanText(wHandle, ( + "# Earth\n" + "@tag: Earth\n" + )) assert index.scanText(nHandle, ( "# Hello World!\n" "@pov: Jane\n" + "@location: Earth\n" "@invalid: John\n" # Checks for issue #688 )) + assert index._tagsIndex.tagHandle("Earth") == wHandle + assert index._tagsIndex.tagHeading("Earth") == "T0001" + assert index._tagsIndex.tagClass("Earth") == "WORLD" + assert index._tagsIndex.tagHandle("Jane") == cHandle assert index._tagsIndex.tagHeading("Jane") == "T0001" assert index._tagsIndex.tagClass("Jane") == "CHARACTER" + assert index.getItemHeading(nHandle, "T0001").title == "Hello World!" # type: ignore assert index.getReferences(nHandle, "T0001") == { "@char": [], "@custom": [], "@entity": [], "@focus": [], - "@location": [], + "@location": ["Earth"], "@object": [], "@plot": [], "@pov": ["Jane"], @@ -283,13 +297,29 @@ def testCoreIndex_CheckThese(mockGUI, fncPath, mockRnd): assert index.checkThese(["@tag", "John"], nHandle) == [True, True] assert index.checkThese(["@pov", "John"], nHandle) == [True, False] assert index.checkThese(["@pov", "Jane"], nHandle) == [True, True] + assert index.checkThese(["@mention", "Jane"], nHandle) == [True, True] assert index.checkThese(["@ pov", "Jane"], nHandle) == [False, False] assert index.checkThese(["@what", "Jane"], nHandle) == [False, False] + # Two w/Class Check + assert index.checkThese(["@pov", "Earth"], nHandle) == [True, False] + assert index.checkThese(["@focus", "Earth"], nHandle) == [True, False] + assert index.checkThese(["@char", "Earth"], nHandle) == [True, False] + assert index.checkThese(["@plot", "Earth"], nHandle) == [True, False] + assert index.checkThese(["@time", "Earth"], nHandle) == [True, False] + assert index.checkThese(["@location", "Earth"], nHandle) == [True, True] + assert index.checkThese(["@object", "Earth"], nHandle) == [True, False] + assert index.checkThese(["@entity", "Earth"], nHandle) == [True, False] + assert index.checkThese(["@custom", "Earth"], nHandle) == [True, False] + assert index.checkThese(["@mention", "Earth"], nHandle) == [True, True] + # Three Items assert index.checkThese(["@tag", "Jane", "John"], cHandle) == [True, True, False] assert index.checkThese(["@who", "Jane", "John"], cHandle) == [False, False, False] assert index.checkThese(["@pov", "Jane", "John"], nHandle) == [True, True, False] + assert index.checkThese(["@pov", "Jane", "Earth"], nHandle) == [True, True, False] + assert index.checkThese(["@mention", "Jane", "Earth"], nHandle) == [True, True, True] + assert index.checkThese(["@mention", "Jane", "Stuff"], nHandle) == [True, True, False] # Parse a Checked Value assert index.parseValue("Jane | Jane Smith") == ("Jane", "Jane Smith") diff --git a/tests/test_gui/test_gui_outline.py b/tests/test_gui/test_gui_outline.py index 12195fa9..9c92820a 100644 --- a/tests/test_gui/test_gui_outline.py +++ b/tests/test_gui/test_gui_outline.py @@ -165,12 +165,12 @@ def testGuiOutline_Main(qtbot, monkeypatch, nwGUI, projPath): # Current Order order = [outlineTree._colIdx[col] for col in outlineTree._treeOrder] - assert order == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16] + assert order == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17] # Move 3 to 0 outlineTree._columnMoved(0, 3, 0) order = [outlineTree._colIdx[col] for col in outlineTree._treeOrder] - assert order == [3, 0, 1, 2, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16] + assert order == [3, 0, 1, 2, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17] # qtbot.stop()