Improve itemEditor test, and refactor actions

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