Fix ActionEvent enums

This commit is contained in:
Veronica Berglyd Olsen
2024-09-18 21:46:44 +02:00
parent 10527afbda
commit cc8d7d9912
10 changed files with 126 additions and 126 deletions
+1 -1
View File
@@ -58,4 +58,4 @@ def testDlgAbout_QtDialog(monkeypatch, nwGUI):
# Open About # Open About
# All it can do is check against a crash # All it can do is check against a crash
nwGUI.showAboutQtDialog() nwGUI.showAboutQtDialog()
nwGUI.mainMenu.aAboutQt.activate(QAction.Trigger) nwGUI.mainMenu.aAboutQt.activate(QAction.ActionEvent.Trigger)
@@ -46,7 +46,7 @@ def testDlgProjSettings_Dialog(qtbot, monkeypatch, nwGUI):
monkeypatch.setattr(GuiProjectSettings, "result", lambda *a: QtAccepted) monkeypatch.setattr(GuiProjectSettings, "result", lambda *a: QtAccepted)
# Check that we cannot open when there is no project # Check that we cannot open when there is no project
nwGUI.mainMenu.aProjectSettings.activate(QAction.Trigger) nwGUI.mainMenu.aProjectSettings.activate(QAction.ActionEvent.Trigger)
assert SHARED.findTopLevelWidget(GuiProjectSettings) is None assert SHARED.findTopLevelWidget(GuiProjectSettings) is None
# Pretend we have a project # Pretend we have a project
@@ -54,7 +54,7 @@ def testDlgProjSettings_Dialog(qtbot, monkeypatch, nwGUI):
SHARED.project.data.setSpellLang("en") SHARED.project.data.setSpellLang("en")
# Get the dialog object # Get the dialog object
nwGUI.mainMenu.aProjectSettings.activate(QAction.Trigger) nwGUI.mainMenu.aProjectSettings.activate(QAction.ActionEvent.Trigger)
qtbot.waitUntil( qtbot.waitUntil(
lambda: SHARED.findTopLevelWidget(GuiProjectSettings) is not None, timeout=1000 lambda: SHARED.findTopLevelWidget(GuiProjectSettings) is not None, timeout=1000
) )
+1 -1
View File
@@ -47,7 +47,7 @@ def testDlgWordList_Dialog(qtbot, monkeypatch, nwGUI, fncPath, projPath):
nwGUI.openProject(projPath) nwGUI.openProject(projPath)
# Load the dialog # Load the dialog
nwGUI.mainMenu.aEditWordList.activate(QAction.Trigger) nwGUI.mainMenu.aEditWordList.activate(QAction.ActionEvent.Trigger)
qtbot.waitUntil(lambda: SHARED.findTopLevelWidget(GuiWordList) is not None, timeout=1000) qtbot.waitUntil(lambda: SHARED.findTopLevelWidget(GuiWordList) is not None, timeout=1000)
wList = SHARED.findTopLevelWidget(GuiWordList) wList = SHARED.findTopLevelWidget(GuiWordList)
+31 -31
View File
@@ -1881,7 +1881,7 @@ def testGuiEditor_Search(qtbot, monkeypatch, nwGUI, prjLipsum):
assert cursor.selectedText() == "est" assert cursor.selectedText() == "est"
# Activate search # Activate search
nwGUI.mainMenu.aFind.activate(QAction.Trigger) nwGUI.mainMenu.aFind.activate(QAction.ActionEvent.Trigger)
assert docSearch.isVisible() assert docSearch.isVisible()
assert docSearch.searchText == "est" assert docSearch.searchText == "est"
@@ -1895,16 +1895,16 @@ def testGuiEditor_Search(qtbot, monkeypatch, nwGUI, prjLipsum):
assert abs(docEditor.getCursorPosition() - 1513) < 3 assert abs(docEditor.getCursorPosition() - 1513) < 3
# Activate loop search # Activate loop search
docSearch.toggleLoop.activate(QAction.Trigger) docSearch.toggleLoop.activate(QAction.ActionEvent.Trigger)
assert docSearch.toggleLoop.isChecked() assert docSearch.toggleLoop.isChecked()
assert CONFIG.searchLoop is True assert CONFIG.searchLoop is True
# Find next by menu Search > Find Next # Find next by menu Search > Find Next
nwGUI.mainMenu.aFindNext.activate(QAction.Trigger) nwGUI.mainMenu.aFindNext.activate(QAction.ActionEvent.Trigger)
assert abs(docEditor.getCursorPosition() - 647) < 3 assert abs(docEditor.getCursorPosition() - 647) < 3
# Close search # Close search
docSearch.cancelSearch.activate(QAction.Trigger) docSearch.cancelSearch.activate(QAction.ActionEvent.Trigger)
assert docSearch.isVisible() is False assert docSearch.isVisible() is False
docEditor.setCursorPosition(15) docEditor.setCursorPosition(15)
@@ -1920,7 +1920,7 @@ def testGuiEditor_Search(qtbot, monkeypatch, nwGUI, prjLipsum):
assert docEditor.getCursorPosition() < 3 # No result assert docEditor.getCursorPosition() < 3 # No result
# Enable RegEx search # Enable RegEx search
docSearch.toggleRegEx.activate(QAction.Trigger) docSearch.toggleRegEx.activate(QAction.ActionEvent.Trigger)
assert docSearch.toggleRegEx.isChecked() assert docSearch.toggleRegEx.isChecked()
assert CONFIG.searchRegEx is True assert CONFIG.searchRegEx is True
@@ -1943,50 +1943,50 @@ def testGuiEditor_Search(qtbot, monkeypatch, nwGUI, prjLipsum):
assert abs(docEditor.getCursorPosition() - 223) < 3 assert abs(docEditor.getCursorPosition() - 223) < 3
# Find next and then prev # Find next and then prev
nwGUI.mainMenu.aFindNext.activate(QAction.Trigger) nwGUI.mainMenu.aFindNext.activate(QAction.ActionEvent.Trigger)
assert abs(docEditor.getCursorPosition() - 324) < 3 assert abs(docEditor.getCursorPosition() - 324) < 3
nwGUI.mainMenu.aFindPrev.activate(QAction.Trigger) nwGUI.mainMenu.aFindPrev.activate(QAction.ActionEvent.Trigger)
assert abs(docEditor.getCursorPosition() - 223) < 3 assert abs(docEditor.getCursorPosition() - 223) < 3
# Make RegEx case sensitive # Make RegEx case sensitive
docSearch.toggleCase.activate(QAction.Trigger) docSearch.toggleCase.activate(QAction.ActionEvent.Trigger)
assert docSearch.toggleCase.isChecked() assert docSearch.toggleCase.isChecked()
assert CONFIG.searchCase is True assert CONFIG.searchCase is True
# Find next/prev (one result) # Find next/prev (one result)
nwGUI.mainMenu.aFindNext.activate(QAction.Trigger) nwGUI.mainMenu.aFindNext.activate(QAction.ActionEvent.Trigger)
assert abs(docEditor.getCursorPosition() - 626) < 3 assert abs(docEditor.getCursorPosition() - 626) < 3
nwGUI.mainMenu.aFindPrev.activate(QAction.Trigger) nwGUI.mainMenu.aFindPrev.activate(QAction.ActionEvent.Trigger)
assert abs(docEditor.getCursorPosition() - 626) < 3 assert abs(docEditor.getCursorPosition() - 626) < 3
nwGUI.mainMenu.aFindNext.activate(QAction.Trigger) nwGUI.mainMenu.aFindNext.activate(QAction.ActionEvent.Trigger)
assert abs(docEditor.getCursorPosition() - 626) < 3 assert abs(docEditor.getCursorPosition() - 626) < 3
# Trigger replace # Trigger replace
nwGUI.mainMenu.aReplace.activate(QAction.Trigger) nwGUI.mainMenu.aReplace.activate(QAction.ActionEvent.Trigger)
docSearch.setReplaceText("foo") docSearch.setReplaceText("foo")
# Disable RegEx case sensitive # Disable RegEx case sensitive
docSearch.toggleCase.activate(QAction.Trigger) docSearch.toggleCase.activate(QAction.ActionEvent.Trigger)
assert docSearch.toggleCase.isChecked() is False assert docSearch.toggleCase.isChecked() is False
assert CONFIG.searchCase is False assert CONFIG.searchCase is False
# Toggle replace preserve case # Toggle replace preserve case
docSearch.toggleMatchCap.activate(QAction.Trigger) docSearch.toggleMatchCap.activate(QAction.ActionEvent.Trigger)
assert docSearch.toggleMatchCap.isChecked() assert docSearch.toggleMatchCap.isChecked()
assert CONFIG.searchMatchCap is True assert CONFIG.searchMatchCap is True
# Replace "Sus" with "Foo" via menu # Replace "Sus" with "Foo" via menu
docEditor.setCursorPosition(605) docEditor.setCursorPosition(605)
nwGUI.mainMenu.aFindNext.activate(QAction.Trigger) nwGUI.mainMenu.aFindNext.activate(QAction.ActionEvent.Trigger)
nwGUI.mainMenu.aReplaceNext.activate(QAction.Trigger) nwGUI.mainMenu.aReplaceNext.activate(QAction.ActionEvent.Trigger)
assert docEditor.getText()[623:634] == "Foopendisse" assert docEditor.getText()[623:634] == "Foopendisse"
# Find next/prev to loop file # Find next/prev to loop file
nwGUI.mainMenu.aFindNext.activate(QAction.Trigger) nwGUI.mainMenu.aFindNext.activate(QAction.ActionEvent.Trigger)
assert abs(docEditor.getCursorPosition() - 223) < 3 assert abs(docEditor.getCursorPosition() - 223) < 3
nwGUI.mainMenu.aFindPrev.activate(QAction.Trigger) nwGUI.mainMenu.aFindPrev.activate(QAction.ActionEvent.Trigger)
assert abs(docEditor.getCursorPosition() - 1805) < 3 assert abs(docEditor.getCursorPosition() - 1805) < 3
nwGUI.mainMenu.aFindNext.activate(QAction.Trigger) nwGUI.mainMenu.aFindNext.activate(QAction.ActionEvent.Trigger)
assert abs(docEditor.getCursorPosition() - 223) < 3 assert abs(docEditor.getCursorPosition() - 223) < 3
# Replace "sus" with "foo" via replace button # Replace "sus" with "foo" via replace button
@@ -1999,53 +1999,53 @@ def testGuiEditor_Search(qtbot, monkeypatch, nwGUI, prjLipsum):
assert docEditor.getText() == origText assert docEditor.getText() == origText
# Disable RegEx search # Disable RegEx search
docSearch.toggleRegEx.activate(QAction.Trigger) docSearch.toggleRegEx.activate(QAction.ActionEvent.Trigger)
assert not docSearch.toggleRegEx.isChecked() assert not docSearch.toggleRegEx.isChecked()
assert CONFIG.searchRegEx is False assert CONFIG.searchRegEx is False
# Close search and select "est" again # Close search and select "est" again
docSearch.cancelSearch.activate(QAction.Trigger) docSearch.cancelSearch.activate(QAction.ActionEvent.Trigger)
docEditor.setCursorPosition(645) docEditor.setCursorPosition(645)
docEditor._makeSelection(QTextCursor.WordUnderCursor) docEditor._makeSelection(QTextCursor.WordUnderCursor)
cursor = docEditor.textCursor() cursor = docEditor.textCursor()
assert cursor.selectedText() == "est" assert cursor.selectedText() == "est"
# Activate search again # Activate search again
nwGUI.mainMenu.aFind.activate(QAction.Trigger) nwGUI.mainMenu.aFind.activate(QAction.ActionEvent.Trigger)
assert docSearch.isVisible() assert docSearch.isVisible()
assert docSearch.searchText == "est" assert docSearch.searchText == "est"
# Enable full word search # Enable full word search
docSearch.toggleWord.activate(QAction.Trigger) docSearch.toggleWord.activate(QAction.ActionEvent.Trigger)
assert docSearch.toggleWord.isChecked() assert docSearch.toggleWord.isChecked()
assert CONFIG.searchWord is True assert CONFIG.searchWord is True
# Only one match # Only one match
nwGUI.mainMenu.aFindNext.activate(QAction.Trigger) nwGUI.mainMenu.aFindNext.activate(QAction.ActionEvent.Trigger)
assert abs(docEditor.getCursorPosition() - 647) < 3 assert abs(docEditor.getCursorPosition() - 647) < 3
nwGUI.mainMenu.aFindNext.activate(QAction.Trigger) nwGUI.mainMenu.aFindNext.activate(QAction.ActionEvent.Trigger)
assert abs(docEditor.getCursorPosition() - 647) < 3 assert abs(docEditor.getCursorPosition() - 647) < 3
# Enable next doc search # Enable next doc search
docSearch.toggleProject.activate(QAction.Trigger) docSearch.toggleProject.activate(QAction.ActionEvent.Trigger)
assert docSearch.toggleProject.isChecked() assert docSearch.toggleProject.isChecked()
assert CONFIG.searchNextFile is True assert CONFIG.searchNextFile is True
# Next match # Next match
nwGUI.mainMenu.aFindNext.activate(QAction.Trigger) nwGUI.mainMenu.aFindNext.activate(QAction.ActionEvent.Trigger)
assert docEditor.docHandle == "2426c6f0ca922" # Next document assert docEditor.docHandle == "2426c6f0ca922" # Next document
nwGUI.mainMenu.aFindNext.activate(QAction.Trigger) nwGUI.mainMenu.aFindNext.activate(QAction.ActionEvent.Trigger)
assert abs(docEditor.getCursorPosition() - 620) < 3 assert abs(docEditor.getCursorPosition() - 620) < 3
nwGUI.mainMenu.aFindNext.activate(QAction.Trigger) nwGUI.mainMenu.aFindNext.activate(QAction.ActionEvent.Trigger)
assert abs(docEditor.getCursorPosition() - 1127) < 3 assert abs(docEditor.getCursorPosition() - 1127) < 3
# Next doc, no match # Next doc, no match
assert CONFIG.searchNextFile is True assert CONFIG.searchNextFile is True
docSearch.setSearchText("abcdef") docSearch.setSearchText("abcdef")
nwGUI.mainMenu.aFindNext.activate(QAction.Trigger) nwGUI.mainMenu.aFindNext.activate(QAction.ActionEvent.Trigger)
assert docEditor.docHandle != "2426c6f0ca922" assert docEditor.docHandle != "2426c6f0ca922"
assert docEditor.docHandle == "04468803b92e1" assert docEditor.docHandle == "04468803b92e1"
nwGUI.mainMenu.aFindNext.activate(QAction.Trigger) nwGUI.mainMenu.aFindNext.activate(QAction.ActionEvent.Trigger)
assert docEditor.docHandle != "04468803b92e1" assert docEditor.docHandle != "04468803b92e1"
assert docEditor.docHandle == "7a992350f3eb6" assert docEditor.docHandle == "7a992350f3eb6"
+1 -1
View File
@@ -133,7 +133,7 @@ def testGuiViewer_Main(qtbot, monkeypatch, nwGUI, prjLipsum):
# Open again via menu # Open again via menu
assert nwGUI.projView.projTree.setSelectedHandle("88243afbe5ed8") assert nwGUI.projView.projTree.setSelectedHandle("88243afbe5ed8")
nwGUI.mainMenu.aViewDoc.activate(QAction.Trigger) nwGUI.mainMenu.aViewDoc.activate(QAction.ActionEvent.Trigger)
# Open context menu # Open context menu
menuOpened = False menuOpened = False
+86 -86
View File
@@ -49,45 +49,45 @@ def testGuiMainMenu_EditFormat(qtbot, monkeypatch, nwGUI, prjLipsum):
cleanText = nwGUI.docEditor.getText()[54:101] cleanText = nwGUI.docEditor.getText()[54:101]
# Bold # Bold
nwGUI.mainMenu.aFmtBold.activate(QAction.Trigger) nwGUI.mainMenu.aFmtBold.activate(QAction.ActionEvent.Trigger)
fmtStr = "**Pellentesque** nec erat ut nulla posuere commodo." fmtStr = "**Pellentesque** nec erat ut nulla posuere commodo."
assert nwGUI.docEditor.getText()[54:105] == fmtStr assert nwGUI.docEditor.getText()[54:105] == fmtStr
nwGUI.mainMenu.aFmtBold.activate(QAction.Trigger) nwGUI.mainMenu.aFmtBold.activate(QAction.ActionEvent.Trigger)
assert nwGUI.docEditor.getText()[54:101] == cleanText assert nwGUI.docEditor.getText()[54:101] == cleanText
# Italic # Italic
nwGUI.mainMenu.aFmtItalic.activate(QAction.Trigger) nwGUI.mainMenu.aFmtItalic.activate(QAction.ActionEvent.Trigger)
fmtStr = "_Pellentesque_ nec erat ut nulla posuere commodo." fmtStr = "_Pellentesque_ nec erat ut nulla posuere commodo."
assert nwGUI.docEditor.getText()[54:103] == fmtStr assert nwGUI.docEditor.getText()[54:103] == fmtStr
nwGUI.mainMenu.aFmtItalic.activate(QAction.Trigger) nwGUI.mainMenu.aFmtItalic.activate(QAction.ActionEvent.Trigger)
assert nwGUI.docEditor.getText()[54:101] == cleanText assert nwGUI.docEditor.getText()[54:101] == cleanText
# Strikethrough # Strikethrough
nwGUI.mainMenu.aFmtStrike.activate(QAction.Trigger) nwGUI.mainMenu.aFmtStrike.activate(QAction.ActionEvent.Trigger)
fmtStr = "~~Pellentesque~~ nec erat ut nulla posuere commodo." fmtStr = "~~Pellentesque~~ nec erat ut nulla posuere commodo."
assert nwGUI.docEditor.getText()[54:105] == fmtStr assert nwGUI.docEditor.getText()[54:105] == fmtStr
nwGUI.mainMenu.aFmtStrike.activate(QAction.Trigger) nwGUI.mainMenu.aFmtStrike.activate(QAction.ActionEvent.Trigger)
assert nwGUI.docEditor.getText()[54:101] == cleanText assert nwGUI.docEditor.getText()[54:101] == cleanText
# Should get us back to plain # Should get us back to plain
nwGUI.mainMenu.aFmtBold.activate(QAction.Trigger) nwGUI.mainMenu.aFmtBold.activate(QAction.ActionEvent.Trigger)
nwGUI.mainMenu.aFmtItalic.activate(QAction.Trigger) nwGUI.mainMenu.aFmtItalic.activate(QAction.ActionEvent.Trigger)
nwGUI.mainMenu.aFmtItalic.activate(QAction.Trigger) nwGUI.mainMenu.aFmtItalic.activate(QAction.ActionEvent.Trigger)
nwGUI.mainMenu.aFmtBold.activate(QAction.Trigger) nwGUI.mainMenu.aFmtBold.activate(QAction.ActionEvent.Trigger)
assert nwGUI.docEditor.getText()[54:101] == cleanText assert nwGUI.docEditor.getText()[54:101] == cleanText
# Double Quotes # Double Quotes
nwGUI.mainMenu.aFmtDQuote.activate(QAction.Trigger) nwGUI.mainMenu.aFmtDQuote.activate(QAction.ActionEvent.Trigger)
fmtStr = "“Pellentesque” nec erat ut nulla posuere commodo." fmtStr = "“Pellentesque” nec erat ut nulla posuere commodo."
assert nwGUI.docEditor.getText()[54:103] == fmtStr assert nwGUI.docEditor.getText()[54:103] == fmtStr
nwGUI.mainMenu.aEditUndo.activate(QAction.Trigger) nwGUI.mainMenu.aEditUndo.activate(QAction.ActionEvent.Trigger)
assert nwGUI.docEditor.getText()[54:101] == cleanText assert nwGUI.docEditor.getText()[54:101] == cleanText
# Single Quotes # Single Quotes
nwGUI.mainMenu.aFmtSQuote.activate(QAction.Trigger) nwGUI.mainMenu.aFmtSQuote.activate(QAction.ActionEvent.Trigger)
fmtStr = "Pellentesque nec erat ut nulla posuere commodo." fmtStr = "Pellentesque nec erat ut nulla posuere commodo."
assert nwGUI.docEditor.getText()[54:103] == fmtStr assert nwGUI.docEditor.getText()[54:103] == fmtStr
nwGUI.mainMenu.aEditUndo.activate(QAction.Trigger) nwGUI.mainMenu.aEditUndo.activate(QAction.ActionEvent.Trigger)
assert nwGUI.docEditor.getText()[54:101] == cleanText assert nwGUI.docEditor.getText()[54:101] == cleanText
# Block Formats # Block Formats
@@ -96,51 +96,51 @@ def testGuiMainMenu_EditFormat(qtbot, monkeypatch, nwGUI, prjLipsum):
nwGUI.docEditor.setCursorPosition(57) nwGUI.docEditor.setCursorPosition(57)
# Header 1 # Header 1
nwGUI.mainMenu.aFmtHead1.activate(QAction.Trigger) nwGUI.mainMenu.aFmtHead1.activate(QAction.ActionEvent.Trigger)
fmtStr = "# Pellentesque nec erat ut nulla posuere commodo." fmtStr = "# Pellentesque nec erat ut nulla posuere commodo."
assert nwGUI.docEditor.getText()[54:103] == fmtStr assert nwGUI.docEditor.getText()[54:103] == fmtStr
# Header 2 # Header 2
nwGUI.mainMenu.aFmtHead2.activate(QAction.Trigger) nwGUI.mainMenu.aFmtHead2.activate(QAction.ActionEvent.Trigger)
fmtStr = "## Pellentesque nec erat ut nulla posuere commodo." fmtStr = "## Pellentesque nec erat ut nulla posuere commodo."
assert nwGUI.docEditor.getText()[54:104] == fmtStr assert nwGUI.docEditor.getText()[54:104] == fmtStr
# Header 3 # Header 3
nwGUI.mainMenu.aFmtHead3.activate(QAction.Trigger) nwGUI.mainMenu.aFmtHead3.activate(QAction.ActionEvent.Trigger)
fmtStr = "### Pellentesque nec erat ut nulla posuere commodo." fmtStr = "### Pellentesque nec erat ut nulla posuere commodo."
assert nwGUI.docEditor.getText()[54:105] == fmtStr assert nwGUI.docEditor.getText()[54:105] == fmtStr
# Header 4 # Header 4
nwGUI.mainMenu.aFmtHead4.activate(QAction.Trigger) nwGUI.mainMenu.aFmtHead4.activate(QAction.ActionEvent.Trigger)
fmtStr = "#### Pellentesque nec erat ut nulla posuere commodo." fmtStr = "#### Pellentesque nec erat ut nulla posuere commodo."
assert nwGUI.docEditor.getText()[54:106] == fmtStr assert nwGUI.docEditor.getText()[54:106] == fmtStr
# Title Format # Title Format
nwGUI.mainMenu.aFmtTitle.activate(QAction.Trigger) nwGUI.mainMenu.aFmtTitle.activate(QAction.ActionEvent.Trigger)
fmtStr = "#! Pellentesque nec erat ut nulla posuere commodo." fmtStr = "#! Pellentesque nec erat ut nulla posuere commodo."
assert nwGUI.docEditor.getText()[54:104] == fmtStr assert nwGUI.docEditor.getText()[54:104] == fmtStr
# Unnumbered Chapter # Unnumbered Chapter
nwGUI.mainMenu.aFmtUnNum.activate(QAction.Trigger) nwGUI.mainMenu.aFmtUnNum.activate(QAction.ActionEvent.Trigger)
fmtStr = "##! Pellentesque nec erat ut nulla posuere commodo." fmtStr = "##! Pellentesque nec erat ut nulla posuere commodo."
assert nwGUI.docEditor.getText()[54:105] == fmtStr assert nwGUI.docEditor.getText()[54:105] == fmtStr
# Hard Scene # Hard Scene
nwGUI.mainMenu.aFmtHardSc.activate(QAction.Trigger) nwGUI.mainMenu.aFmtHardSc.activate(QAction.ActionEvent.Trigger)
fmtStr = "###! Pellentesque nec erat ut nulla posuere commodo." fmtStr = "###! Pellentesque nec erat ut nulla posuere commodo."
assert nwGUI.docEditor.getText()[54:106] == fmtStr assert nwGUI.docEditor.getText()[54:106] == fmtStr
# Clear Format # Clear Format
nwGUI.mainMenu.aFmtNoFormat.activate(QAction.Trigger) nwGUI.mainMenu.aFmtNoFormat.activate(QAction.ActionEvent.Trigger)
assert nwGUI.docEditor.getText()[54:101] == cleanText assert nwGUI.docEditor.getText()[54:101] == cleanText
# Comment On # Comment On
nwGUI.mainMenu.aFmtComment.activate(QAction.Trigger) nwGUI.mainMenu.aFmtComment.activate(QAction.ActionEvent.Trigger)
fmtStr = "% Pellentesque nec erat ut nulla posuere commodo." fmtStr = "% Pellentesque nec erat ut nulla posuere commodo."
assert nwGUI.docEditor.getText()[54:103] == fmtStr assert nwGUI.docEditor.getText()[54:103] == fmtStr
# Comment Off # Comment Off
nwGUI.mainMenu.aFmtComment.activate(QAction.Trigger) nwGUI.mainMenu.aFmtComment.activate(QAction.ActionEvent.Trigger)
assert nwGUI.docEditor.getText()[54:101] == cleanText assert nwGUI.docEditor.getText()[54:101] == cleanText
# Check comment with no space before text # Check comment with no space before text
@@ -149,26 +149,26 @@ def testGuiMainMenu_EditFormat(qtbot, monkeypatch, nwGUI, prjLipsum):
fmtStr = "%Pellentesque nec erat ut nulla posuere commodo." fmtStr = "%Pellentesque nec erat ut nulla posuere commodo."
assert nwGUI.docEditor.getText()[54:102] == fmtStr assert nwGUI.docEditor.getText()[54:102] == fmtStr
nwGUI.mainMenu.aFmtNoFormat.activate(QAction.Trigger) nwGUI.mainMenu.aFmtNoFormat.activate(QAction.ActionEvent.Trigger)
assert nwGUI.docEditor.getText()[54:101] == cleanText assert nwGUI.docEditor.getText()[54:101] == cleanText
# Undo/Redo # Undo/Redo
nwGUI.mainMenu.aEditUndo.activate(QAction.Trigger) nwGUI.mainMenu.aEditUndo.activate(QAction.ActionEvent.Trigger)
fmtStr = "%Pellentesque nec erat ut nulla posuere commodo." fmtStr = "%Pellentesque nec erat ut nulla posuere commodo."
assert nwGUI.docEditor.getText()[54:102] == fmtStr assert nwGUI.docEditor.getText()[54:102] == fmtStr
nwGUI.mainMenu.aEditRedo.activate(QAction.Trigger) nwGUI.mainMenu.aEditRedo.activate(QAction.ActionEvent.Trigger)
assert nwGUI.docEditor.getText()[54:101] == cleanText assert nwGUI.docEditor.getText()[54:101] == cleanText
# Cut, Copy and Paste # Cut, Copy and Paste
nwGUI.docEditor.setCursorPosition(54) nwGUI.docEditor.setCursorPosition(54)
nwGUI.docEditor._makeSelection(QTextCursor.WordUnderCursor) nwGUI.docEditor._makeSelection(QTextCursor.WordUnderCursor)
nwGUI.mainMenu.aEditCut.activate(QAction.Trigger) nwGUI.mainMenu.aEditCut.activate(QAction.ActionEvent.Trigger)
assert nwGUI.docEditor.getText()[54:104] == ( assert nwGUI.docEditor.getText()[54:104] == (
" nec erat ut nulla posuere commodo. Curabitur nisi" " nec erat ut nulla posuere commodo. Curabitur nisi"
) )
nwGUI.mainMenu.aEditPaste.activate(QAction.Trigger) nwGUI.mainMenu.aEditPaste.activate(QAction.ActionEvent.Trigger)
assert nwGUI.docEditor.getText()[54:104] == ( assert nwGUI.docEditor.getText()[54:104] == (
"Pellentesque nec erat ut nulla posuere commodo. Cu" "Pellentesque nec erat ut nulla posuere commodo. Cu"
) )
@@ -176,21 +176,21 @@ def testGuiMainMenu_EditFormat(qtbot, monkeypatch, nwGUI, prjLipsum):
nwGUI.docEditor.setCursorPosition(54) nwGUI.docEditor.setCursorPosition(54)
nwGUI.docEditor._makeSelection(QTextCursor.WordUnderCursor) nwGUI.docEditor._makeSelection(QTextCursor.WordUnderCursor)
nwGUI.mainMenu.aEditCopy.activate(QAction.Trigger) nwGUI.mainMenu.aEditCopy.activate(QAction.ActionEvent.Trigger)
assert nwGUI.docEditor.getText()[54:104] == ( assert nwGUI.docEditor.getText()[54:104] == (
"Pellentesque nec erat ut nulla posuere commodo. Cu" "Pellentesque nec erat ut nulla posuere commodo. Cu"
) )
nwGUI.docEditor.setCursorPosition(54) nwGUI.docEditor.setCursorPosition(54)
nwGUI.mainMenu.aEditPaste.activate(QAction.Trigger) nwGUI.mainMenu.aEditPaste.activate(QAction.ActionEvent.Trigger)
assert nwGUI.docEditor.getText()[54:104] == ( assert nwGUI.docEditor.getText()[54:104] == (
"PellentesquePellentesque nec erat ut nulla posuere" "PellentesquePellentesque nec erat ut nulla posuere"
) )
nwGUI.mainMenu.aEditUndo.activate(QAction.Trigger) nwGUI.mainMenu.aEditUndo.activate(QAction.ActionEvent.Trigger)
# Select Paragraph/All # Select Paragraph/All
nwGUI.docEditor.setCursorPosition(57) nwGUI.docEditor.setCursorPosition(57)
nwGUI.mainMenu.aSelectPar.activate(QAction.Trigger) nwGUI.mainMenu.aSelectPar.activate(QAction.ActionEvent.Trigger)
cursor = nwGUI.docEditor.textCursor() cursor = nwGUI.docEditor.textCursor()
assert cursor.selectedText() == ( assert cursor.selectedText() == (
"Pellentesque nec erat ut nulla posuere commodo. Curabitur nisi augue, imperdiet et porta " "Pellentesque nec erat ut nulla posuere commodo. Curabitur nisi augue, imperdiet et porta "
@@ -203,7 +203,7 @@ def testGuiMainMenu_EditFormat(qtbot, monkeypatch, nwGUI, prjLipsum):
) )
nwGUI.docEditor.setCursorPosition(57) nwGUI.docEditor.setCursorPosition(57)
nwGUI.mainMenu.aSelectAll.activate(QAction.Trigger) nwGUI.mainMenu.aSelectAll.activate(QAction.ActionEvent.Trigger)
cursor = nwGUI.docEditor.textCursor() cursor = nwGUI.docEditor.textCursor()
assert len(cursor.selectedText()) == 1910 assert len(cursor.selectedText()) == 1910
@@ -219,32 +219,32 @@ def testGuiMainMenu_EditFormat(qtbot, monkeypatch, nwGUI, prjLipsum):
nwGUI.docEditor.setCursorPosition(0) nwGUI.docEditor.setCursorPosition(0)
# Left Align # Left Align
nwGUI.mainMenu.aFmtAlignLeft.activate(QAction.Trigger) nwGUI.mainMenu.aFmtAlignLeft.activate(QAction.ActionEvent.Trigger)
fmtStr = "A single, short paragraph. <<" fmtStr = "A single, short paragraph. <<"
assert nwGUI.docEditor.getText()[:29] == fmtStr assert nwGUI.docEditor.getText()[:29] == fmtStr
# Right Align # Right Align
nwGUI.mainMenu.aFmtAlignRight.activate(QAction.Trigger) nwGUI.mainMenu.aFmtAlignRight.activate(QAction.ActionEvent.Trigger)
fmtStr = ">> A single, short paragraph." fmtStr = ">> A single, short paragraph."
assert nwGUI.docEditor.getText()[:29] == fmtStr assert nwGUI.docEditor.getText()[:29] == fmtStr
# Centre Align # Centre Align
nwGUI.mainMenu.aFmtAlignCentre.activate(QAction.Trigger) nwGUI.mainMenu.aFmtAlignCentre.activate(QAction.ActionEvent.Trigger)
fmtStr = ">> A single, short paragraph. <<" fmtStr = ">> A single, short paragraph. <<"
assert nwGUI.docEditor.getText()[:32] == fmtStr assert nwGUI.docEditor.getText()[:32] == fmtStr
# Left Indent # Left Indent
nwGUI.mainMenu.aFmtIndentLeft.activate(QAction.Trigger) nwGUI.mainMenu.aFmtIndentLeft.activate(QAction.ActionEvent.Trigger)
fmtStr = "> A single, short paragraph." fmtStr = "> A single, short paragraph."
assert nwGUI.docEditor.getText()[:28] == fmtStr assert nwGUI.docEditor.getText()[:28] == fmtStr
# Right Indent # Right Indent
nwGUI.mainMenu.aFmtIndentRight.activate(QAction.Trigger) nwGUI.mainMenu.aFmtIndentRight.activate(QAction.ActionEvent.Trigger)
fmtStr = "> A single, short paragraph. <" fmtStr = "> A single, short paragraph. <"
assert nwGUI.docEditor.getText()[:30] == fmtStr assert nwGUI.docEditor.getText()[:30] == fmtStr
# No Format # No Format
nwGUI.mainMenu.aFmtNoFormat.activate(QAction.Trigger) nwGUI.mainMenu.aFmtNoFormat.activate(QAction.ActionEvent.Trigger)
assert nwGUI.docEditor.getText()[:30] == cleanText assert nwGUI.docEditor.getText()[:30] == cleanText
# Other Checks # Other Checks
@@ -256,16 +256,16 @@ def testGuiMainMenu_EditFormat(qtbot, monkeypatch, nwGUI, prjLipsum):
"Also text with \"double\" quotes which are \"less tricky\".\n\n" "Also text with \"double\" quotes which are \"less tricky\".\n\n"
)) ))
nwGUI.mainMenu.aSelectAll.activate(QAction.Trigger) nwGUI.mainMenu.aSelectAll.activate(QAction.ActionEvent.Trigger)
nwGUI.mainMenu.aFmtReplSng.activate(QAction.Trigger) nwGUI.mainMenu.aFmtReplSng.activate(QAction.ActionEvent.Trigger)
assert nwGUI.docEditor.getText() == ( assert nwGUI.docEditor.getText() == (
"### New Text\n\n" "### New Text\n\n"
"Text with single quotes and tricky stuffs.\n\n" "Text with single quotes and tricky stuffs.\n\n"
"Also text with \"double\" quotes which are \"less tricky\".\n\n" "Also text with \"double\" quotes which are \"less tricky\".\n\n"
) )
nwGUI.mainMenu.aSelectAll.activate(QAction.Trigger) nwGUI.mainMenu.aSelectAll.activate(QAction.ActionEvent.Trigger)
nwGUI.mainMenu.aFmtReplDbl.activate(QAction.Trigger) nwGUI.mainMenu.aFmtReplDbl.activate(QAction.ActionEvent.Trigger)
assert nwGUI.docEditor.getText() == ( assert nwGUI.docEditor.getText() == (
"### New Text\n\n" "### New Text\n\n"
"Text with single quotes and tricky stuffs.\n\n" "Text with single quotes and tricky stuffs.\n\n"
@@ -281,7 +281,7 @@ def testGuiMainMenu_EditFormat(qtbot, monkeypatch, nwGUI, prjLipsum):
"Here is some text\non multiple\nlines.\n\n" "Here is some text\non multiple\nlines.\n\n"
"With another paragraph\nhere." "With another paragraph\nhere."
)) ))
nwGUI.mainMenu.aFmtRmBreaks.activate(QAction.Trigger) nwGUI.mainMenu.aFmtRmBreaks.activate(QAction.ActionEvent.Trigger)
assert nwGUI.docEditor.getText() == ( assert nwGUI.docEditor.getText() == (
"### New Text\n\n" "### New Text\n\n"
"@char: Someone\n" "@char: Someone\n"
@@ -303,7 +303,7 @@ def testGuiMainMenu_EditFormat(qtbot, monkeypatch, nwGUI, prjLipsum):
cursor.setPosition(74) cursor.setPosition(74)
cursor.movePosition(QTextCursor.Right, QTextCursor.KeepAnchor, 29) cursor.movePosition(QTextCursor.Right, QTextCursor.KeepAnchor, 29)
nwGUI.docEditor.setTextCursor(cursor) nwGUI.docEditor.setTextCursor(cursor)
nwGUI.mainMenu.aFmtRmBreaks.activate(QAction.Trigger) nwGUI.mainMenu.aFmtRmBreaks.activate(QAction.ActionEvent.Trigger)
assert nwGUI.docEditor.getText() == ( assert nwGUI.docEditor.getText() == (
"### New Text\n\n" "### New Text\n\n"
"@char: Someone\n" "@char: Someone\n"
@@ -367,95 +367,95 @@ def testGuiMainMenu_Insert(qtbot, monkeypatch, nwGUI, fncPath, projPath, mockRnd
nwGUI.docEditor.clear() nwGUI.docEditor.clear()
# Check Menu Entries # Check Menu Entries
nwGUI.mainMenu.aInsENDash.activate(QAction.Trigger) nwGUI.mainMenu.aInsENDash.activate(QAction.ActionEvent.Trigger)
assert nwGUI.docEditor.getText() == nwUnicode.U_ENDASH assert nwGUI.docEditor.getText() == nwUnicode.U_ENDASH
nwGUI.docEditor.clear() nwGUI.docEditor.clear()
nwGUI.mainMenu.aInsEMDash.activate(QAction.Trigger) nwGUI.mainMenu.aInsEMDash.activate(QAction.ActionEvent.Trigger)
assert nwGUI.docEditor.getText() == nwUnicode.U_EMDASH assert nwGUI.docEditor.getText() == nwUnicode.U_EMDASH
nwGUI.docEditor.clear() nwGUI.docEditor.clear()
nwGUI.mainMenu.aInsHorBar.activate(QAction.Trigger) nwGUI.mainMenu.aInsHorBar.activate(QAction.ActionEvent.Trigger)
assert nwGUI.docEditor.getText() == nwUnicode.U_HBAR assert nwGUI.docEditor.getText() == nwUnicode.U_HBAR
nwGUI.docEditor.clear() nwGUI.docEditor.clear()
nwGUI.mainMenu.aInsFigDash.activate(QAction.Trigger) nwGUI.mainMenu.aInsFigDash.activate(QAction.ActionEvent.Trigger)
assert nwGUI.docEditor.getText() == nwUnicode.U_FGDASH assert nwGUI.docEditor.getText() == nwUnicode.U_FGDASH
nwGUI.docEditor.clear() nwGUI.docEditor.clear()
nwGUI.mainMenu.aInsQuoteLS.activate(QAction.Trigger) nwGUI.mainMenu.aInsQuoteLS.activate(QAction.ActionEvent.Trigger)
assert nwGUI.docEditor.getText() == CONFIG.fmtSQuoteOpen assert nwGUI.docEditor.getText() == CONFIG.fmtSQuoteOpen
nwGUI.docEditor.clear() nwGUI.docEditor.clear()
nwGUI.mainMenu.aInsQuoteRS.activate(QAction.Trigger) nwGUI.mainMenu.aInsQuoteRS.activate(QAction.ActionEvent.Trigger)
assert nwGUI.docEditor.getText() == CONFIG.fmtSQuoteClose assert nwGUI.docEditor.getText() == CONFIG.fmtSQuoteClose
nwGUI.docEditor.clear() nwGUI.docEditor.clear()
nwGUI.mainMenu.aInsQuoteLD.activate(QAction.Trigger) nwGUI.mainMenu.aInsQuoteLD.activate(QAction.ActionEvent.Trigger)
assert nwGUI.docEditor.getText() == CONFIG.fmtDQuoteOpen assert nwGUI.docEditor.getText() == CONFIG.fmtDQuoteOpen
nwGUI.docEditor.clear() nwGUI.docEditor.clear()
nwGUI.mainMenu.aInsQuoteRD.activate(QAction.Trigger) nwGUI.mainMenu.aInsQuoteRD.activate(QAction.ActionEvent.Trigger)
assert nwGUI.docEditor.getText() == CONFIG.fmtDQuoteClose assert nwGUI.docEditor.getText() == CONFIG.fmtDQuoteClose
nwGUI.docEditor.clear() nwGUI.docEditor.clear()
nwGUI.mainMenu.aInsMSApos.activate(QAction.Trigger) nwGUI.mainMenu.aInsMSApos.activate(QAction.ActionEvent.Trigger)
assert nwGUI.docEditor.getText() == nwUnicode.U_MAPOS assert nwGUI.docEditor.getText() == nwUnicode.U_MAPOS
nwGUI.docEditor.clear() nwGUI.docEditor.clear()
nwGUI.mainMenu.aInsEllipsis.activate(QAction.Trigger) nwGUI.mainMenu.aInsEllipsis.activate(QAction.ActionEvent.Trigger)
assert nwGUI.docEditor.getText() == nwUnicode.U_HELLIP assert nwGUI.docEditor.getText() == nwUnicode.U_HELLIP
nwGUI.docEditor.clear() nwGUI.docEditor.clear()
nwGUI.mainMenu.aInsPrime.activate(QAction.Trigger) nwGUI.mainMenu.aInsPrime.activate(QAction.ActionEvent.Trigger)
assert nwGUI.docEditor.getText() == nwUnicode.U_PRIME assert nwGUI.docEditor.getText() == nwUnicode.U_PRIME
nwGUI.docEditor.clear() nwGUI.docEditor.clear()
nwGUI.mainMenu.aInsDPrime.activate(QAction.Trigger) nwGUI.mainMenu.aInsDPrime.activate(QAction.ActionEvent.Trigger)
assert nwGUI.docEditor.getText() == nwUnicode.U_DPRIME assert nwGUI.docEditor.getText() == nwUnicode.U_DPRIME
nwGUI.docEditor.clear() nwGUI.docEditor.clear()
nwGUI.mainMenu.aInsBullet.activate(QAction.Trigger) nwGUI.mainMenu.aInsBullet.activate(QAction.ActionEvent.Trigger)
assert nwGUI.docEditor.getText() == nwUnicode.U_BULL assert nwGUI.docEditor.getText() == nwUnicode.U_BULL
nwGUI.docEditor.clear() nwGUI.docEditor.clear()
nwGUI.mainMenu.aInsHyBull.activate(QAction.Trigger) nwGUI.mainMenu.aInsHyBull.activate(QAction.ActionEvent.Trigger)
assert nwGUI.docEditor.getText() == nwUnicode.U_HYBULL assert nwGUI.docEditor.getText() == nwUnicode.U_HYBULL
nwGUI.docEditor.clear() nwGUI.docEditor.clear()
nwGUI.mainMenu.aInsFlower.activate(QAction.Trigger) nwGUI.mainMenu.aInsFlower.activate(QAction.ActionEvent.Trigger)
assert nwGUI.docEditor.getText() == nwUnicode.U_FLOWER assert nwGUI.docEditor.getText() == nwUnicode.U_FLOWER
nwGUI.docEditor.clear() nwGUI.docEditor.clear()
nwGUI.mainMenu.aInsPerMille.activate(QAction.Trigger) nwGUI.mainMenu.aInsPerMille.activate(QAction.ActionEvent.Trigger)
assert nwGUI.docEditor.getText() == nwUnicode.U_PERMIL assert nwGUI.docEditor.getText() == nwUnicode.U_PERMIL
nwGUI.docEditor.clear() nwGUI.docEditor.clear()
nwGUI.mainMenu.aInsDegree.activate(QAction.Trigger) nwGUI.mainMenu.aInsDegree.activate(QAction.ActionEvent.Trigger)
assert nwGUI.docEditor.getText() == nwUnicode.U_DEGREE assert nwGUI.docEditor.getText() == nwUnicode.U_DEGREE
nwGUI.docEditor.clear() nwGUI.docEditor.clear()
nwGUI.mainMenu.aInsMinus.activate(QAction.Trigger) nwGUI.mainMenu.aInsMinus.activate(QAction.ActionEvent.Trigger)
assert nwGUI.docEditor.getText() == nwUnicode.U_MINUS assert nwGUI.docEditor.getText() == nwUnicode.U_MINUS
nwGUI.docEditor.clear() nwGUI.docEditor.clear()
nwGUI.mainMenu.aInsTimes.activate(QAction.Trigger) nwGUI.mainMenu.aInsTimes.activate(QAction.ActionEvent.Trigger)
assert nwGUI.docEditor.getText() == nwUnicode.U_TIMES assert nwGUI.docEditor.getText() == nwUnicode.U_TIMES
nwGUI.docEditor.clear() nwGUI.docEditor.clear()
nwGUI.mainMenu.aInsDivide.activate(QAction.Trigger) nwGUI.mainMenu.aInsDivide.activate(QAction.ActionEvent.Trigger)
assert nwGUI.docEditor.getText() == nwUnicode.U_DIVIDE assert nwGUI.docEditor.getText() == nwUnicode.U_DIVIDE
nwGUI.docEditor.clear() nwGUI.docEditor.clear()
nwGUI.mainMenu.aInsNBSpace.activate(QAction.Trigger) nwGUI.mainMenu.aInsNBSpace.activate(QAction.ActionEvent.Trigger)
assert nwGUI.docEditor.getText() == nwUnicode.U_NBSP assert nwGUI.docEditor.getText() == nwUnicode.U_NBSP
nwGUI.docEditor.clear() nwGUI.docEditor.clear()
nwGUI.mainMenu.aInsThinSpace.activate(QAction.Trigger) nwGUI.mainMenu.aInsThinSpace.activate(QAction.ActionEvent.Trigger)
assert nwGUI.docEditor.getText() == nwUnicode.U_THSP assert nwGUI.docEditor.getText() == nwUnicode.U_THSP
nwGUI.docEditor.clear() nwGUI.docEditor.clear()
nwGUI.mainMenu.aInsThinNBSpace.activate(QAction.Trigger) nwGUI.mainMenu.aInsThinNBSpace.activate(QAction.ActionEvent.Trigger)
assert nwGUI.docEditor.getText() == nwUnicode.U_THNBSP assert nwGUI.docEditor.getText() == nwUnicode.U_THNBSP
nwGUI.docEditor.clear() nwGUI.docEditor.clear()
@@ -463,43 +463,43 @@ def testGuiMainMenu_Insert(qtbot, monkeypatch, nwGUI, fncPath, projPath, mockRnd
# =============== # ===============
nwGUI.docEditor.setPlainText("Stuff") nwGUI.docEditor.setPlainText("Stuff")
nwGUI.mainMenu.mInsKWItems[nwKeyWords.TAG_KEY][0].activate(QAction.Trigger) nwGUI.mainMenu.mInsKWItems[nwKeyWords.TAG_KEY][0].activate(QAction.ActionEvent.Trigger)
assert nwGUI.docEditor.getText() == "Stuff\n%s: " % nwKeyWords.TAG_KEY assert nwGUI.docEditor.getText() == "Stuff\n%s: " % nwKeyWords.TAG_KEY
nwGUI.docEditor.setPlainText("Stuff") nwGUI.docEditor.setPlainText("Stuff")
nwGUI.mainMenu.mInsKWItems[nwKeyWords.POV_KEY][0].activate(QAction.Trigger) nwGUI.mainMenu.mInsKWItems[nwKeyWords.POV_KEY][0].activate(QAction.ActionEvent.Trigger)
assert nwGUI.docEditor.getText() == "Stuff\n%s: " % nwKeyWords.POV_KEY assert nwGUI.docEditor.getText() == "Stuff\n%s: " % nwKeyWords.POV_KEY
nwGUI.docEditor.setPlainText("Stuff") nwGUI.docEditor.setPlainText("Stuff")
nwGUI.mainMenu.mInsKWItems[nwKeyWords.FOCUS_KEY][0].activate(QAction.Trigger) nwGUI.mainMenu.mInsKWItems[nwKeyWords.FOCUS_KEY][0].activate(QAction.ActionEvent.Trigger)
assert nwGUI.docEditor.getText() == "Stuff\n%s: " % nwKeyWords.FOCUS_KEY assert nwGUI.docEditor.getText() == "Stuff\n%s: " % nwKeyWords.FOCUS_KEY
nwGUI.docEditor.setPlainText("Stuff") nwGUI.docEditor.setPlainText("Stuff")
nwGUI.mainMenu.mInsKWItems[nwKeyWords.CHAR_KEY][0].activate(QAction.Trigger) nwGUI.mainMenu.mInsKWItems[nwKeyWords.CHAR_KEY][0].activate(QAction.ActionEvent.Trigger)
assert nwGUI.docEditor.getText() == "Stuff\n%s: " % nwKeyWords.CHAR_KEY assert nwGUI.docEditor.getText() == "Stuff\n%s: " % nwKeyWords.CHAR_KEY
nwGUI.docEditor.setPlainText("Stuff") nwGUI.docEditor.setPlainText("Stuff")
nwGUI.mainMenu.mInsKWItems[nwKeyWords.PLOT_KEY][0].activate(QAction.Trigger) nwGUI.mainMenu.mInsKWItems[nwKeyWords.PLOT_KEY][0].activate(QAction.ActionEvent.Trigger)
assert nwGUI.docEditor.getText() == "Stuff\n%s: " % nwKeyWords.PLOT_KEY assert nwGUI.docEditor.getText() == "Stuff\n%s: " % nwKeyWords.PLOT_KEY
nwGUI.docEditor.setPlainText("Stuff") nwGUI.docEditor.setPlainText("Stuff")
nwGUI.mainMenu.mInsKWItems[nwKeyWords.TIME_KEY][0].activate(QAction.Trigger) nwGUI.mainMenu.mInsKWItems[nwKeyWords.TIME_KEY][0].activate(QAction.ActionEvent.Trigger)
assert nwGUI.docEditor.getText() == "Stuff\n%s: " % nwKeyWords.TIME_KEY assert nwGUI.docEditor.getText() == "Stuff\n%s: " % nwKeyWords.TIME_KEY
nwGUI.docEditor.setPlainText("Stuff") nwGUI.docEditor.setPlainText("Stuff")
nwGUI.mainMenu.mInsKWItems[nwKeyWords.WORLD_KEY][0].activate(QAction.Trigger) nwGUI.mainMenu.mInsKWItems[nwKeyWords.WORLD_KEY][0].activate(QAction.ActionEvent.Trigger)
assert nwGUI.docEditor.getText() == "Stuff\n%s: " % nwKeyWords.WORLD_KEY assert nwGUI.docEditor.getText() == "Stuff\n%s: " % nwKeyWords.WORLD_KEY
nwGUI.docEditor.setPlainText("Stuff") nwGUI.docEditor.setPlainText("Stuff")
nwGUI.mainMenu.mInsKWItems[nwKeyWords.OBJECT_KEY][0].activate(QAction.Trigger) nwGUI.mainMenu.mInsKWItems[nwKeyWords.OBJECT_KEY][0].activate(QAction.ActionEvent.Trigger)
assert nwGUI.docEditor.getText() == "Stuff\n%s: " % nwKeyWords.OBJECT_KEY assert nwGUI.docEditor.getText() == "Stuff\n%s: " % nwKeyWords.OBJECT_KEY
nwGUI.docEditor.setPlainText("Stuff") nwGUI.docEditor.setPlainText("Stuff")
nwGUI.mainMenu.mInsKWItems[nwKeyWords.ENTITY_KEY][0].activate(QAction.Trigger) nwGUI.mainMenu.mInsKWItems[nwKeyWords.ENTITY_KEY][0].activate(QAction.ActionEvent.Trigger)
assert nwGUI.docEditor.getText() == "Stuff\n%s: " % nwKeyWords.ENTITY_KEY assert nwGUI.docEditor.getText() == "Stuff\n%s: " % nwKeyWords.ENTITY_KEY
nwGUI.docEditor.setPlainText("Stuff") nwGUI.docEditor.setPlainText("Stuff")
nwGUI.mainMenu.mInsKWItems[nwKeyWords.CUSTOM_KEY][0].activate(QAction.Trigger) nwGUI.mainMenu.mInsKWItems[nwKeyWords.CUSTOM_KEY][0].activate(QAction.ActionEvent.Trigger)
assert nwGUI.docEditor.getText() == "Stuff\n%s: " % nwKeyWords.CUSTOM_KEY assert nwGUI.docEditor.getText() == "Stuff\n%s: " % nwKeyWords.CUSTOM_KEY
# Faulty Keyword Inserts # Faulty Keyword Inserts
@@ -514,26 +514,26 @@ def testGuiMainMenu_Insert(qtbot, monkeypatch, nwGUI, fncPath, projPath, mockRnd
# ======================= # =======================
nwGUI.docEditor.setPlainText("Stuff\n") nwGUI.docEditor.setPlainText("Stuff\n")
nwGUI.mainMenu.aInsSynopsis.activate(QAction.Trigger) nwGUI.mainMenu.aInsSynopsis.activate(QAction.ActionEvent.Trigger)
assert nwGUI.docEditor.getText() == "Stuff\n%Synopsis: \n" assert nwGUI.docEditor.getText() == "Stuff\n%Synopsis: \n"
nwGUI.docEditor.setPlainText("Stuff\n") nwGUI.docEditor.setPlainText("Stuff\n")
nwGUI.mainMenu.aInsShort.activate(QAction.Trigger) nwGUI.mainMenu.aInsShort.activate(QAction.ActionEvent.Trigger)
assert nwGUI.docEditor.getText() == "Stuff\n%Short: \n" assert nwGUI.docEditor.getText() == "Stuff\n%Short: \n"
# Insert Break or Space # Insert Break or Space
# ===================== # =====================
nwGUI.docEditor.setPlainText("### Stuff\n") nwGUI.docEditor.setPlainText("### Stuff\n")
nwGUI.mainMenu.aInsNewPage.activate(QAction.Trigger) nwGUI.mainMenu.aInsNewPage.activate(QAction.ActionEvent.Trigger)
assert nwGUI.docEditor.getText() == "[newpage]\n### Stuff\n" assert nwGUI.docEditor.getText() == "[newpage]\n### Stuff\n"
nwGUI.docEditor.setPlainText("### Stuff\n") nwGUI.docEditor.setPlainText("### Stuff\n")
nwGUI.mainMenu.aInsVSpaceS.activate(QAction.Trigger) nwGUI.mainMenu.aInsVSpaceS.activate(QAction.ActionEvent.Trigger)
assert nwGUI.docEditor.getText() == "[vspace]\n### Stuff\n" assert nwGUI.docEditor.getText() == "[vspace]\n### Stuff\n"
nwGUI.docEditor.setPlainText("### Stuff\n") nwGUI.docEditor.setPlainText("### Stuff\n")
nwGUI.mainMenu.aInsVSpaceM.activate(QAction.Trigger) nwGUI.mainMenu.aInsVSpaceM.activate(QAction.ActionEvent.Trigger)
assert nwGUI.docEditor.getText() == "[vspace:2]\n### Stuff\n" assert nwGUI.docEditor.getText() == "[vspace:2]\n### Stuff\n"
nwGUI.docEditor.clear() nwGUI.docEditor.clear()
@@ -572,13 +572,13 @@ def testGuiMainMenu_Insert(qtbot, monkeypatch, nwGUI, fncPath, projPath, mockRnd
assert nwGUI.docEditor.getText() == "Bar" assert nwGUI.docEditor.getText() == "Bar"
# Finally, accept the replaced text, this time we use the menu entry to trigger it # Finally, accept the replaced text, this time we use the menu entry to trigger it
nwGUI.mainMenu.aImportFile.activate(QAction.Trigger) nwGUI.mainMenu.aImportFile.activate(QAction.ActionEvent.Trigger)
assert nwGUI.docEditor.getText() == "Foo" assert nwGUI.docEditor.getText() == "Foo"
# Reveal File Location # Reveal File Location
# ==================== # ====================
nwGUI.mainMenu.aFileDetails.activate(QAction.Trigger) nwGUI.mainMenu.aFileDetails.activate(QAction.ActionEvent.Trigger)
path = str(projPath / "content" / "000000000000f.nwd") path = str(projPath / "content" / "000000000000f.nwd")
assert SHARED.lastAlert.endswith(f"File Location: {path}") assert SHARED.lastAlert.endswith(f"File Location: {path}")
+1 -1
View File
@@ -152,7 +152,7 @@ def testGuiOutline_Main(qtbot, monkeypatch, nwGUI, projPath):
# Trigger the menu entry for all hidden columns # Trigger the menu entry for all hidden columns
for hItem in nwOutline: for hItem in nwOutline:
if outlineTree.DEF_HIDDEN[hItem]: if outlineTree.DEF_HIDDEN[hItem]:
outlineMenu.actionMap[hItem].activate(QAction.Trigger) outlineMenu.actionMap[hItem].activate(QAction.ActionEvent.Trigger)
# Now no columns should be hidden # Now no columns should be hidden
outlineTree._saveHeaderState() outlineTree._saveHeaderState()
+1 -1
View File
@@ -35,7 +35,7 @@ from tests.tools import C, buildTestProject
def testToolLipsum_Main(qtbot, monkeypatch, nwGUI, projPath, mockRnd): def testToolLipsum_Main(qtbot, monkeypatch, nwGUI, projPath, mockRnd):
"""Test the Lorem Ipsum tool.""" """Test the Lorem Ipsum tool."""
# Check that we cannot open when there is no project # Check that we cannot open when there is no project
nwGUI.mainMenu.aLipsumText.activate(QAction.Trigger) nwGUI.mainMenu.aLipsumText.activate(QAction.ActionEvent.Trigger)
assert SHARED.findTopLevelWidget(GuiLipsum) is None assert SHARED.findTopLevelWidget(GuiLipsum) is None
buildTestProject(nwGUI, projPath) buildTestProject(nwGUI, projPath)
+1 -1
View File
@@ -47,7 +47,7 @@ def testToolManuscript_Init(monkeypatch, qtbot, nwGUI, projPath, mockRnd):
SHARED.project.storage.getDocument(C.hChapterDoc).writeDocument("## A Chapter\n\n\t\tHi") SHARED.project.storage.getDocument(C.hChapterDoc).writeDocument("## A Chapter\n\n\t\tHi")
allText = "New Novel\nBy Jane Doe\nA Chapter\n\t\tHi" allText = "New Novel\nBy Jane Doe\nA Chapter\n\t\tHi"
nwGUI.mainMenu.aBuildManuscript.activate(QAction.Trigger) nwGUI.mainMenu.aBuildManuscript.activate(QAction.ActionEvent.Trigger)
qtbot.waitUntil(lambda: SHARED.findTopLevelWidget(GuiManuscript) is not None, timeout=1000) qtbot.waitUntil(lambda: SHARED.findTopLevelWidget(GuiManuscript) is not None, timeout=1000)
manus = SHARED.findTopLevelWidget(GuiManuscript) manus = SHARED.findTopLevelWidget(GuiManuscript)
assert isinstance(manus, GuiManuscript) assert isinstance(manus, GuiManuscript)
+1 -1
View File
@@ -45,7 +45,7 @@ def testToolWritingStats_Main(qtbot, monkeypatch, nwGUI, projPath, tstPaths):
sessFile = projPath / "meta" / nwFiles.SESS_FILE sessFile = projPath / "meta" / nwFiles.SESS_FILE
# Open the Writing Stats dialog # Open the Writing Stats dialog
nwGUI.mainMenu.aWritingStats.activate(QAction.Trigger) nwGUI.mainMenu.aWritingStats.activate(QAction.ActionEvent.Trigger)
qtbot.waitUntil(lambda: SHARED.findTopLevelWidget(GuiWritingStats) is not None, timeout=1000) qtbot.waitUntil(lambda: SHARED.findTopLevelWidget(GuiWritingStats) is not None, timeout=1000)
sessLog = SHARED.findTopLevelWidget(GuiWritingStats) sessLog = SHARED.findTopLevelWidget(GuiWritingStats)