Files
novelWriter/tests/test_tools/test_tools_lipsum.py
T
2022-11-09 22:43:48 +01:00

73 lines
2.2 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
"""
novelWriter Lorem Ipsum Tool Tester
=====================================
This file is a part of novelWriter
Copyright 20182022, Veronica Berglyd Olsen
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
"""
import pytest
from tools import C, getGuiItem, buildTestProject
from PyQt5.QtWidgets import QAction
from novelwriter.tools import GuiLipsum
@pytest.mark.gui
def testToolLipsum_Main(qtbot, nwGUI, projPath, mockRnd):
"""Test the Lorem Ipsum tool.
"""
# Check that we cannot open when there is no project
nwGUI.mainMenu.aLipsumText.activate(QAction.Trigger)
assert getGuiItem("GuiLipsum") is None
# Create a new project
buildTestProject(nwGUI, projPath)
assert nwGUI.openDocument(C.hSceneDoc) is True
assert len(nwGUI.docEditor.getText()) == 15
# Open the tool
nwGUI.mainMenu.aLipsumText.activate(QAction.Trigger)
qtbot.waitUntil(lambda: getGuiItem("GuiLipsum") is not None, timeout=1000)
nwLipsum = getGuiItem("GuiLipsum")
assert isinstance(nwLipsum, GuiLipsum)
# Insert paragraphs
nwGUI.docEditor.setCursorPosition(100) # End of document
nwLipsum.paraCount.setValue(2)
nwLipsum._doInsert()
theText = nwGUI.docEditor.getText()
assert "Lorem ipsum" in theText
assert len(theText) == 965
# Insert random paragraph
nwGUI.docEditor.setCursorPosition(1000) # End of document
nwLipsum.randSwitch.setChecked(True)
nwLipsum.paraCount.setValue(1)
nwLipsum._doInsert()
theText = nwGUI.docEditor.getText()
assert len(theText) > 965
# Close
nwLipsum._doClose()
# qtbot.stop()
# END Test testToolLipsum_Main