Fix test coverage

This commit is contained in:
Veronica Berglyd Olsen
2024-05-27 21:45:31 +02:00
parent 6289840a74
commit cf14f84652
2 changed files with 35 additions and 2 deletions
+12 -1
View File
@@ -334,6 +334,7 @@ def testCoreToQTextDocument_TextBlockFormats(mockGUI):
"""Test text block formats in the ToQTextDocument class."""
project = NWProject()
qdoc = ToQTextDocument(project)
qdoc.setFirstLineIndent(True, 2.0, False)
qdoc.initDocument(CONFIG.textFont, THEME)
qdoc._isNovel = True
@@ -351,10 +352,11 @@ def testCoreToQTextDocument_TextBlockFormats(mockGUI):
"> Left Indent\n\n"
"Right Indent <\n\n"
"> Double Indent <\n\n"
"Text Indent\n\n"
)
qdoc.tokenizeText()
qdoc.doConvert()
assert qdoc.document.blockCount() == 7
assert qdoc.document.blockCount() == 8
# 0: Scene
block = qdoc.document.findBlockByNumber(0)
@@ -402,6 +404,15 @@ def testCoreToQTextDocument_TextBlockFormats(mockGUI):
assert bFmt.leftMargin() == qdoc._mIndent
assert bFmt.rightMargin() == qdoc._mIndent
# 7: Text Indent
block = qdoc.document.findBlockByNumber(7)
assert block.text() == "Text Indent"
bFmt = block.blockFormat()
assert bFmt.alignment() == QtAlignAbsolute
assert bFmt.textIndent() == qdoc._tIndent
assert bFmt.leftMargin() == 0.0
assert bFmt.rightMargin() == 0.0
# Unreachable
# ===========
# Some formatting markers are currently not reachable
+23 -1
View File
@@ -106,7 +106,7 @@ def testGuiTheme_Main(qtbot, nwGUI, tstPaths):
@pytest.mark.gui
def testGuiTheme_Theme(qtbot, monkeypatch, nwGUI):
def testGuiTheme_Theme(qtbot, monkeypatch, nwGUI, tstPaths):
"""Test the theme part of the class."""
mainTheme = SHARED.theme
@@ -155,6 +155,28 @@ def testGuiTheme_Theme(qtbot, monkeypatch, nwGUI):
wCol = QApplication.style().standardPalette().color(QPalette.ColorRole.Window).getRgb()
assert mainTheme._guiPalette.color(QPalette.ColorRole.Window).getRgb() == wCol
# Mock Dark Theme
# ===============
mockTheme: Path = tstPaths.cnfDir / "themes" / "test.conf"
mockTheme.write_text(
"[Main]\n"
"name = Test\n"
"\n"
"[Palette]\n"
"window = 0, 0, 0\n"
"windowtext = 255, 255, 255\n"
"\n"
"[GUI]\n"
"helptext = 0, 0, 0\n"
)
mainTheme._availThemes["test"] = mockTheme
CONFIG.guiTheme = "test"
assert mainTheme.loadTheme() is True
assert mainTheme.isLightTheme is False
assert mainTheme.helpText.getRgb() == (165, 165, 165, 255)
# Load Default Light Theme
# ========================