Merge pull request #423 from vkbo/more_tests
Adding Tests for Project Load and Outline View
This commit is contained in:
@@ -249,8 +249,8 @@ class GuiOutlineDetails(QScrollArea):
|
||||
self.itemValue.setText(nwItem.itemStatus)
|
||||
|
||||
self.cCValue.setText("{:n}".format(checkInt(novIdx["cCount"], 0)))
|
||||
self.wCValue.setText("{:n}".format(checkInt(novIdx["pCount"], 0)))
|
||||
self.pCValue.setText("{:n}".format(checkInt(novIdx["wCount"], 0)))
|
||||
self.wCValue.setText("{:n}".format(checkInt(novIdx["wCount"], 0)))
|
||||
self.pCValue.setText("{:n}".format(checkInt(novIdx["pCount"], 0)))
|
||||
|
||||
self.synopValue.setText(novIdx["synopsis"])
|
||||
|
||||
|
||||
@@ -48,7 +48,7 @@
|
||||
<expanded>True</expanded>
|
||||
</item>
|
||||
<item handle="7a992350f3eb6" order="0" parent="b3643d0f92e32">
|
||||
<name>Lorem Ipusm</name>
|
||||
<name>Lorem Ipsum</name>
|
||||
<type>FILE</type>
|
||||
<class>NOVEL</class>
|
||||
<status>Finished</status>
|
||||
|
||||
+113
-4
@@ -8,14 +8,17 @@ import json
|
||||
from nwtools import cmpFiles
|
||||
|
||||
from os import path
|
||||
from PyQt5.QtCore import Qt
|
||||
from PyQt5.QtWidgets import QAction
|
||||
from PyQt5.QtCore import Qt, QPoint
|
||||
from PyQt5.QtWidgets import QAction, QDialogButtonBox, QTreeWidgetItem
|
||||
|
||||
from nw.gui import (
|
||||
GuiProjectSettings, GuiItemEditor, GuiAbout, GuiBuildNovel,
|
||||
GuiDocMerge, GuiDocSplit, GuiWritingStats, GuiProjectWizard
|
||||
GuiDocMerge, GuiDocSplit, GuiWritingStats, GuiProjectWizard,
|
||||
GuiProjectLoad
|
||||
)
|
||||
from nw.constants import (
|
||||
nwItemType, nwItemLayout, nwItemClass, nwDocAction, nwUnicode, nwOutline
|
||||
)
|
||||
from nw.constants import nwItemType, nwItemLayout, nwItemClass, nwDocAction, nwUnicode
|
||||
|
||||
keyDelay = 2
|
||||
stepDelay = 20
|
||||
@@ -1064,3 +1067,109 @@ def testInsertMenu(qtbot, nwTempGUI, nwFuncTemp, nwTemp):
|
||||
|
||||
# qtbot.stopForInteraction()
|
||||
nwGUI.closeMain()
|
||||
|
||||
@pytest.mark.gui
|
||||
def testLoadProject(qtbot, nwTempGUI, nwTemp):
|
||||
nwGUI = nw.main(["--testmode", "--config=%s" % nwTempGUI, "--data=%s" % nwTemp])
|
||||
qtbot.addWidget(nwGUI)
|
||||
nwGUI.show()
|
||||
qtbot.waitForWindowShown(nwGUI)
|
||||
qtbot.wait(stepDelay)
|
||||
|
||||
nwLoad = GuiProjectLoad(nwGUI)
|
||||
nwLoad.show()
|
||||
|
||||
recentCount = nwLoad.listBox.topLevelItemCount()
|
||||
assert recentCount > 1
|
||||
|
||||
selItem = nwLoad.listBox.topLevelItem(1)
|
||||
selPath = selItem.data(nwLoad.C_NAME, Qt.UserRole)
|
||||
|
||||
nwLoad.selPath.setText("")
|
||||
nwLoad.listBox.setCurrentItem(selItem)
|
||||
assert nwLoad.selPath.text() == selPath
|
||||
|
||||
qtbot.mouseClick(nwLoad.buttonBox.button(QDialogButtonBox.Open), Qt.LeftButton)
|
||||
assert nwLoad.openPath == selPath
|
||||
assert nwLoad.openState == nwLoad.OPEN_STATE
|
||||
|
||||
del nwLoad
|
||||
nwLoad = GuiProjectLoad(nwGUI)
|
||||
nwLoad.show()
|
||||
|
||||
qtbot.mouseClick(nwLoad.buttonBox.button(QDialogButtonBox.Cancel), Qt.LeftButton)
|
||||
assert nwLoad.openPath is None
|
||||
assert nwLoad.openState == nwLoad.NONE_STATE
|
||||
|
||||
nwLoad.show()
|
||||
qtbot.mouseClick(nwLoad.newButton, Qt.LeftButton)
|
||||
assert nwLoad.openPath is None
|
||||
assert nwLoad.openState == nwLoad.NEW_STATE
|
||||
|
||||
nwLoad.show()
|
||||
nwLoad._keyPressDelete()
|
||||
assert nwLoad.listBox.topLevelItemCount() == recentCount - 1
|
||||
|
||||
nwLoad.close()
|
||||
# qtbot.stopForInteraction()
|
||||
nwGUI.closeMain()
|
||||
|
||||
@pytest.mark.gui
|
||||
def testOutline(qtbot, nwTempBuild, nwLipsum, nwTemp):
|
||||
|
||||
nwGUI = nw.main(["--testmode", "--config=%s" % nwTempBuild, "--data=%s" % nwTemp])
|
||||
qtbot.addWidget(nwGUI)
|
||||
nwGUI.show()
|
||||
qtbot.waitForWindowShown(nwGUI)
|
||||
qtbot.wait(stepDelay)
|
||||
|
||||
assert nwGUI.openProject(nwLipsum)
|
||||
nwGUI.mainConf.lastPath = nwTempBuild
|
||||
|
||||
nwGUI.rebuildIndex()
|
||||
nwGUI.tabWidget.setCurrentIndex(nwGUI.idxTabProj)
|
||||
|
||||
assert nwGUI.projView.topLevelItemCount() > 0
|
||||
|
||||
# Context Menu
|
||||
nwGUI.projView._headerRightClick(QPoint(1, 1))
|
||||
nwGUI.projView.headerMenu.actionMap[nwOutline.CCOUNT].activate(QAction.Trigger)
|
||||
nwGUI.projView.headerMenu.close()
|
||||
qtbot.mouseClick(nwGUI.projView, Qt.LeftButton)
|
||||
|
||||
nwGUI.projView._loadHeaderState()
|
||||
assert not nwGUI.projView.colHidden[nwOutline.CCOUNT]
|
||||
|
||||
# First Item
|
||||
nwGUI.rebuildOutline()
|
||||
selItem = nwGUI.projView.topLevelItem(0)
|
||||
assert isinstance(selItem, QTreeWidgetItem)
|
||||
|
||||
nwGUI.projView.setCurrentItem(selItem)
|
||||
assert nwGUI.projMeta.titleLabel.text() == "<b>Title</b>"
|
||||
assert nwGUI.projMeta.titleValue.text() == "Lorem Ipsum"
|
||||
assert nwGUI.projMeta.fileValue.text() == "Lorem Ipsum"
|
||||
assert nwGUI.projMeta.itemValue.text() == "Finished"
|
||||
|
||||
assert nwGUI.projMeta.cCValue.text() == "122"
|
||||
assert nwGUI.projMeta.wCValue.text() == "18"
|
||||
assert nwGUI.projMeta.pCValue.text() == "2"
|
||||
|
||||
# Scene One
|
||||
actItem = nwGUI.projView.topLevelItem(1)
|
||||
chpItem = actItem.child(0)
|
||||
selItem = chpItem.child(0)
|
||||
|
||||
nwGUI.projView.setCurrentItem(selItem)
|
||||
assert nwGUI.projMeta.titleLabel.text() == "<b>Scene</b>"
|
||||
assert nwGUI.projMeta.titleValue.text() == "Scene One"
|
||||
assert nwGUI.projMeta.fileValue.text() == "Scene One"
|
||||
assert nwGUI.projMeta.itemValue.text() == "Finished"
|
||||
|
||||
# Click POV Link
|
||||
assert nwGUI.projMeta.povKeyValue.text() == "<a href='#pov=Bod'>Bod</a>"
|
||||
nwGUI.projMeta._tagClicked("#pov=Bod")
|
||||
assert nwGUI.docViewer.theHandle == "4c4f28287af27"
|
||||
|
||||
# qtbot.stopForInteraction()
|
||||
nwGUI.closeMain()
|
||||
|
||||
Reference in New Issue
Block a user