Improve itemEditor test, and refactor actions
This commit is contained in:
@@ -13,7 +13,7 @@ jobs:
|
|||||||
- name: Python Setup
|
- name: Python Setup
|
||||||
uses: actions/setup-python@v1
|
uses: actions/setup-python@v1
|
||||||
with:
|
with:
|
||||||
python-version: 3.7
|
python-version: 3
|
||||||
architecture: x64
|
architecture: x64
|
||||||
- name: Checkout Source
|
- name: Checkout Source
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v2
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
name: python 3.6
|
name: Linux (3.6)
|
||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
@@ -7,7 +7,7 @@ on:
|
|||||||
branches: [ main, dev ]
|
branches: [ main, dev ]
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
pyTest36:
|
testLinux36:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Python Setup
|
- name: Python Setup
|
||||||
@@ -18,16 +18,16 @@ jobs:
|
|||||||
- name: Install Packages
|
- name: Install Packages
|
||||||
run: |
|
run: |
|
||||||
sudo apt update
|
sudo apt update
|
||||||
sudo apt install xvfb libenchant-dev qt5-default
|
sudo apt install libenchant-dev qt5-default
|
||||||
- name: Checkout Source
|
- name: Checkout Source
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v2
|
||||||
- name: Install Dependencies
|
- name: Install Dependencies
|
||||||
run: |
|
run: |
|
||||||
pip install --upgrade pip
|
pip install --upgrade pip
|
||||||
pip install -r requirements.txt
|
pip install -r requirements.txt
|
||||||
pip install PyVirtualDisplay
|
|
||||||
pip install pytest-timeout
|
pip install pytest-timeout
|
||||||
pip install pytest-xvfb
|
|
||||||
pip install pytest-qt
|
pip install pytest-qt
|
||||||
- name: Run Tests
|
- name: Run Tests
|
||||||
run: xvfb-run pytest -v --timeout=60
|
run: |
|
||||||
|
export QT_QPA_PLATFORM=offscreen
|
||||||
|
pytest -v --timeout=60
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
name: python 3.7
|
name: Linux (3.7)
|
||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
@@ -7,7 +7,7 @@ on:
|
|||||||
branches: [ main, dev ]
|
branches: [ main, dev ]
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
pyTest37:
|
testLinux37:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Python Setup
|
- name: Python Setup
|
||||||
@@ -18,16 +18,16 @@ jobs:
|
|||||||
- name: Install Packages
|
- name: Install Packages
|
||||||
run: |
|
run: |
|
||||||
sudo apt update
|
sudo apt update
|
||||||
sudo apt install xvfb libenchant-dev qt5-default
|
sudo apt install libenchant-dev qt5-default
|
||||||
- name: Checkout Source
|
- name: Checkout Source
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v2
|
||||||
- name: Install Dependencies
|
- name: Install Dependencies
|
||||||
run: |
|
run: |
|
||||||
pip install --upgrade pip
|
pip install --upgrade pip
|
||||||
pip install -r requirements.txt
|
pip install -r requirements.txt
|
||||||
pip install PyVirtualDisplay
|
|
||||||
pip install pytest-timeout
|
pip install pytest-timeout
|
||||||
pip install pytest-xvfb
|
|
||||||
pip install pytest-qt
|
pip install pytest-qt
|
||||||
- name: Run Tests
|
- name: Run Tests
|
||||||
run: xvfb-run pytest -v --timeout=60
|
run: |
|
||||||
|
export QT_QPA_PLATFORM=offscreen
|
||||||
|
pytest -v --timeout=60
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
name: python 3.8
|
name: Linux (3.8)
|
||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
@@ -7,7 +7,7 @@ on:
|
|||||||
branches: [ main, dev ]
|
branches: [ main, dev ]
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
pyTest38Cov:
|
testLinux38:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Python Setup
|
- name: Python Setup
|
||||||
@@ -18,20 +18,20 @@ jobs:
|
|||||||
- name: Install Packages
|
- name: Install Packages
|
||||||
run: |
|
run: |
|
||||||
sudo apt update
|
sudo apt update
|
||||||
sudo apt install xvfb libenchant-dev qt5-default
|
sudo apt install libenchant-dev qt5-default
|
||||||
- name: Checkout Source
|
- name: Checkout Source
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v2
|
||||||
- name: Install Dependencies
|
- name: Install Dependencies
|
||||||
run: |
|
run: |
|
||||||
pip install --upgrade pip
|
pip install --upgrade pip
|
||||||
pip install -r requirements.txt
|
pip install -r requirements.txt
|
||||||
pip install PyVirtualDisplay
|
|
||||||
pip install pytest-timeout
|
pip install pytest-timeout
|
||||||
pip install pytest-cov
|
pip install pytest-cov
|
||||||
pip install pytest-xvfb
|
|
||||||
pip install pytest-qt
|
pip install pytest-qt
|
||||||
pip install codecov
|
pip install codecov
|
||||||
- name: Run Tests
|
- name: Run Tests
|
||||||
run: xvfb-run pytest -v --cov=nw --timeout=60
|
run: |
|
||||||
|
export QT_QPA_PLATFORM=offscreen
|
||||||
|
pytest -v --timeout=60
|
||||||
- name: Upload to Codecov
|
- name: Upload to Codecov
|
||||||
uses: codecov/codecov-action@v1
|
uses: codecov/codecov-action@v1
|
||||||
@@ -7,7 +7,7 @@ on:
|
|||||||
branches: [ main, dev ]
|
branches: [ main, dev ]
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
pyTestMac38:
|
testMac38:
|
||||||
runs-on: macos-latest
|
runs-on: macos-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Python Setup
|
- name: Python Setup
|
||||||
@@ -25,8 +25,12 @@ jobs:
|
|||||||
pip install --upgrade pip
|
pip install --upgrade pip
|
||||||
pip install -r requirements.txt
|
pip install -r requirements.txt
|
||||||
pip install pytest-timeout
|
pip install pytest-timeout
|
||||||
|
pip install pytest-cov
|
||||||
pip install pytest-qt
|
pip install pytest-qt
|
||||||
|
pip install codecov
|
||||||
- name: Run Tests
|
- name: Run Tests
|
||||||
run: |
|
run: |
|
||||||
export QT_QPA_PLATFORM=offscreen
|
export QT_QPA_PLATFORM=offscreen
|
||||||
pytest -v --timeout=60
|
pytest -v --timeout=60
|
||||||
|
- name: Upload to Codecov
|
||||||
|
uses: codecov/codecov-action@v1
|
||||||
@@ -0,0 +1,32 @@
|
|||||||
|
name: Windows (3.8)
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches: [ main, dev ]
|
||||||
|
pull_request:
|
||||||
|
branches: [ main, dev ]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
testWin38:
|
||||||
|
runs-on: windows-latest
|
||||||
|
steps:
|
||||||
|
- name: Python Setup
|
||||||
|
uses: actions/setup-python@v1
|
||||||
|
with:
|
||||||
|
python-version: 3.8
|
||||||
|
architecture: x64
|
||||||
|
- name: Checkout Source
|
||||||
|
uses: actions/checkout@v2
|
||||||
|
- name: Install Dependencies
|
||||||
|
run: |
|
||||||
|
pip install --upgrade pip
|
||||||
|
pip install -r requirements.txt
|
||||||
|
pip install pytest-timeout
|
||||||
|
pip install pytest-cov
|
||||||
|
pip install pytest-qt
|
||||||
|
pip install codecov
|
||||||
|
- name: Run Tests
|
||||||
|
run: |
|
||||||
|
pytest -v --timeout=60
|
||||||
|
- name: Upload to Codecov
|
||||||
|
uses: codecov/codecov-action@v1
|
||||||
+1
-1
@@ -133,7 +133,7 @@ class GuiDocMerge(QDialog):
|
|||||||
|
|
||||||
theDoc.openDocument(nHandle, False)
|
theDoc.openDocument(nHandle, False)
|
||||||
theDoc.saveDocument(theText)
|
theDoc.saveDocument(theText)
|
||||||
self.theParent.treeView.revealTreeItem(nHandle)
|
self.theParent.treeView.revealNewTreeItem(nHandle)
|
||||||
self.theParent.openDocument(nHandle, doScroll=True)
|
self.theParent.openDocument(nHandle, doScroll=True)
|
||||||
|
|
||||||
self._doClose()
|
self._doClose()
|
||||||
|
|||||||
+2
-2
@@ -178,7 +178,7 @@ class GuiDocSplit(QDialog):
|
|||||||
fHandle = self.theProject.newFolder(
|
fHandle = self.theProject.newFolder(
|
||||||
srcItem.itemName, srcItem.itemClass, srcItem.parHandle
|
srcItem.itemName, srcItem.itemClass, srcItem.parHandle
|
||||||
)
|
)
|
||||||
self.theParent.treeView.revealTreeItem(fHandle)
|
self.theParent.treeView.revealNewTreeItem(fHandle)
|
||||||
logger.verbose("Creating folder %s" % fHandle)
|
logger.verbose("Creating folder %s" % fHandle)
|
||||||
|
|
||||||
# Loop through, and create the files
|
# Loop through, and create the files
|
||||||
@@ -213,7 +213,7 @@ class GuiDocSplit(QDialog):
|
|||||||
theDoc.openDocument(nHandle, False)
|
theDoc.openDocument(nHandle, False)
|
||||||
theDoc.saveDocument(theText)
|
theDoc.saveDocument(theText)
|
||||||
theDoc.clearDocument()
|
theDoc.clearDocument()
|
||||||
self.theParent.treeView.revealTreeItem(nHandle)
|
self.theParent.treeView.revealNewTreeItem(nHandle)
|
||||||
|
|
||||||
self._doClose()
|
self._doClose()
|
||||||
|
|
||||||
|
|||||||
+2
-2
@@ -240,12 +240,12 @@ class GuiProjectTree(QTreeWidget):
|
|||||||
|
|
||||||
# Add the new item to the tree
|
# Add the new item to the tree
|
||||||
if tHandle is not None:
|
if tHandle is not None:
|
||||||
self.revealTreeItem(tHandle, nHandle)
|
self.revealNewTreeItem(tHandle, nHandle)
|
||||||
self.theParent.editItem(tHandle)
|
self.theParent.editItem(tHandle)
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def revealTreeItem(self, tHandle, nHandle=None):
|
def revealNewTreeItem(self, tHandle, nHandle=None):
|
||||||
"""Reveal a newly added project item in the project tree.
|
"""Reveal a newly added project item in the project tree.
|
||||||
"""
|
"""
|
||||||
nwItem = self.theProject.projTree[tHandle]
|
nwItem = self.theProject.projTree[tHandle]
|
||||||
|
|||||||
+7
-8
@@ -659,14 +659,13 @@ class GuiMain(QMainWindow):
|
|||||||
return
|
return
|
||||||
|
|
||||||
logger.verbose("Requesting change to item %s" % tHandle)
|
logger.verbose("Requesting change to item %s" % tHandle)
|
||||||
if self.mainConf.showGUI:
|
dlgProj = GuiItemEditor(self, self.theProject, tHandle)
|
||||||
dlgProj = GuiItemEditor(self, self.theProject, tHandle)
|
dlgProj.exec_()
|
||||||
dlgProj.exec_()
|
if dlgProj.result() == QDialog.Accepted:
|
||||||
if dlgProj.result() == QDialog.Accepted:
|
self.treeView.setTreeItemValues(tHandle)
|
||||||
self.treeView.setTreeItemValues(tHandle)
|
self.treeMeta.updateViewBox(tHandle)
|
||||||
self.treeMeta.updateViewBox(tHandle)
|
self.docEditor.updateDocInfo(tHandle)
|
||||||
self.docEditor.updateDocInfo(tHandle)
|
self.docViewer.updateDocInfo(tHandle)
|
||||||
self.docViewer.updateDocInfo(tHandle)
|
|
||||||
|
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|||||||
@@ -44,7 +44,7 @@
|
|||||||
<type>ROOT</type>
|
<type>ROOT</type>
|
||||||
<class>NOVEL</class>
|
<class>NOVEL</class>
|
||||||
<status>New</status>
|
<status>New</status>
|
||||||
<expanded>False</expanded>
|
<expanded>True</expanded>
|
||||||
</item>
|
</item>
|
||||||
<item handle="25fc0e7096fc6" order="0" parent="73475cb40a568">
|
<item handle="25fc0e7096fc6" order="0" parent="73475cb40a568">
|
||||||
<name>Title Page</name>
|
<name>Title Page</name>
|
||||||
@@ -63,7 +63,7 @@
|
|||||||
<type>FOLDER</type>
|
<type>FOLDER</type>
|
||||||
<class>NOVEL</class>
|
<class>NOVEL</class>
|
||||||
<status>New</status>
|
<status>New</status>
|
||||||
<expanded>False</expanded>
|
<expanded>True</expanded>
|
||||||
</item>
|
</item>
|
||||||
<item handle="98010bd9270f9" order="0" parent="31489056e0916">
|
<item handle="98010bd9270f9" order="0" parent="31489056e0916">
|
||||||
<name>New Chapter</name>
|
<name>New Chapter</name>
|
||||||
|
|||||||
+19
-5
@@ -139,7 +139,7 @@ def testProjectSettings(qtbot, monkeypatch, yesToAll, nwFuncTemp, nwTempGUI, nwR
|
|||||||
nwGUI.closeMain()
|
nwGUI.closeMain()
|
||||||
|
|
||||||
@pytest.mark.gui
|
@pytest.mark.gui
|
||||||
def testItemEditor(qtbot, yesToAll, nwFuncTemp, nwTempGUI, nwRef, nwTemp):
|
def testItemEditor(qtbot, yesToAll, monkeypatch, nwFuncTemp, nwTempGUI, nwRef, nwTemp):
|
||||||
nwGUI = nw.main(["--testmode", "--config=%s" % nwTemp, "--data=%s" % nwTemp])
|
nwGUI = nw.main(["--testmode", "--config=%s" % nwTemp, "--data=%s" % nwTemp])
|
||||||
qtbot.addWidget(nwGUI)
|
qtbot.addWidget(nwGUI)
|
||||||
nwGUI.show()
|
nwGUI.show()
|
||||||
@@ -150,8 +150,16 @@ def testItemEditor(qtbot, yesToAll, nwFuncTemp, nwTempGUI, nwRef, nwTemp):
|
|||||||
nwGUI.theProject.projTree.setSeed(42)
|
nwGUI.theProject.projTree.setSeed(42)
|
||||||
assert nwGUI.newProject({"projPath": nwFuncTemp})
|
assert nwGUI.newProject({"projPath": nwFuncTemp})
|
||||||
assert nwGUI.openDocument("0e17daca5f3e1")
|
assert nwGUI.openDocument("0e17daca5f3e1")
|
||||||
|
assert nwGUI.treeView.setSelectedHandle("0e17daca5f3e1", doScroll=True)
|
||||||
|
|
||||||
|
monkeypatch.setattr(GuiItemEditor, "exec_", lambda *args: None)
|
||||||
|
nwGUI.mainMenu.aEditItem.activate(QAction.Trigger)
|
||||||
|
qtbot.waitUntil(lambda: getGuiItem("GuiItemEditor") is not None, timeout=1000)
|
||||||
|
|
||||||
|
itemEdit = getGuiItem("GuiItemEditor")
|
||||||
|
assert isinstance(itemEdit, GuiItemEditor)
|
||||||
|
itemEdit.show()
|
||||||
|
|
||||||
itemEdit = GuiItemEditor(nwGUI, nwGUI.theProject, "0e17daca5f3e1")
|
|
||||||
qtbot.addWidget(itemEdit)
|
qtbot.addWidget(itemEdit)
|
||||||
|
|
||||||
assert itemEdit.editName.text() == "New Scene"
|
assert itemEdit.editName.text() == "New Scene"
|
||||||
@@ -168,7 +176,13 @@ def testItemEditor(qtbot, yesToAll, nwFuncTemp, nwTempGUI, nwRef, nwTemp):
|
|||||||
assert not itemEdit.editExport.isChecked()
|
assert not itemEdit.editExport.isChecked()
|
||||||
itemEdit._doSave()
|
itemEdit._doSave()
|
||||||
|
|
||||||
itemEdit = GuiItemEditor(nwGUI, nwGUI.theProject, "0e17daca5f3e1")
|
nwGUI.mainMenu.aEditItem.activate(QAction.Trigger)
|
||||||
|
qtbot.waitUntil(lambda: getGuiItem("GuiItemEditor") is not None, timeout=1000)
|
||||||
|
|
||||||
|
itemEdit = getGuiItem("GuiItemEditor")
|
||||||
|
assert isinstance(itemEdit, GuiItemEditor)
|
||||||
|
itemEdit.show()
|
||||||
|
|
||||||
qtbot.addWidget(itemEdit)
|
qtbot.addWidget(itemEdit)
|
||||||
assert itemEdit.editName.text() == "Just a Page"
|
assert itemEdit.editName.text() == "Just a Page"
|
||||||
assert itemEdit.editStatus.currentData() == "Note"
|
assert itemEdit.editStatus.currentData() == "Note"
|
||||||
@@ -194,8 +208,8 @@ def testItemEditor(qtbot, yesToAll, nwFuncTemp, nwTempGUI, nwRef, nwTemp):
|
|||||||
copyfile(projFile, testFile)
|
copyfile(projFile, testFile)
|
||||||
assert cmpFiles(testFile, refFile, [2, 6, 7, 8])
|
assert cmpFiles(testFile, refFile, [2, 6, 7, 8])
|
||||||
|
|
||||||
nwGUI.closeMain()
|
|
||||||
# qtbot.stopForInteraction()
|
# qtbot.stopForInteraction()
|
||||||
|
nwGUI.closeMain()
|
||||||
|
|
||||||
@pytest.mark.gui
|
@pytest.mark.gui
|
||||||
def testWritingStatsExport(qtbot, monkeypatch, yesToAll, nwFuncTemp, nwTemp):
|
def testWritingStatsExport(qtbot, monkeypatch, yesToAll, nwFuncTemp, nwTemp):
|
||||||
@@ -857,7 +871,7 @@ def testNewProjectWizard(qtbot, monkeypatch, yesToAll, nwMinimal, nwTemp):
|
|||||||
# Final Page
|
# Final Page
|
||||||
finalPage = nwWiz.currentPage()
|
finalPage = nwWiz.currentPage()
|
||||||
assert isinstance(finalPage, ProjWizardFinalPage)
|
assert isinstance(finalPage, ProjWizardFinalPage)
|
||||||
assert nwWiz.button(QWizard.FinishButton).isEnabled()
|
assert nwWiz.button(QWizard.FinishButton).isEnabled() # But we don't click it
|
||||||
|
|
||||||
# Check Data
|
# Check Data
|
||||||
projData = nwGUI._assembleProjectWizardData(nwWiz)
|
projData = nwGUI._assembleProjectWizardData(nwWiz)
|
||||||
|
|||||||
@@ -64,6 +64,8 @@ def testLaunch(qtbot, nwFuncTemp, nwTemp):
|
|||||||
["--testmode", "--logfile=%s" % logFile, "--config=%s" % nwFuncTemp, "--data=%s" % nwTemp]
|
["--testmode", "--logfile=%s" % logFile, "--config=%s" % nwFuncTemp, "--data=%s" % nwTemp]
|
||||||
)
|
)
|
||||||
assert os.path.isfile(logFile)
|
assert os.path.isfile(logFile)
|
||||||
|
nwGUI.closeMain()
|
||||||
|
nwGUI.close()
|
||||||
|
|
||||||
nwGUI = nw.main(
|
nwGUI = nw.main(
|
||||||
["--testmode", "--logfile=%s" % logFile, "--config=%s" % nwFuncTemp, "--data=%s" % nwTemp]
|
["--testmode", "--logfile=%s" % logFile, "--config=%s" % nwFuncTemp, "--data=%s" % nwTemp]
|
||||||
|
|||||||
Reference in New Issue
Block a user