Make tests not depend on minimal project settings

This commit is contained in:
Veronica Berglyd Olsen
2022-05-21 17:33:58 +02:00
parent b4ea5bc8d0
commit 06d39ea352
18 changed files with 124 additions and 67 deletions
+2 -2
View File
@@ -23,7 +23,7 @@ import os
import pytest
from mock import causeOSError
from tools import getGuiItem, readFile, writeFile
from tools import getGuiItem, readFile, writeFile, buildTestProject
from PyQt5.QtWidgets import QAction, QMessageBox, QDialog
@@ -41,7 +41,7 @@ def testDlgMerge_Main(qtbot, monkeypatch, nwGUI, fncProj, mockRnd):
monkeypatch.setattr(QMessageBox, "critical", lambda *a: QMessageBox.Ok)
# Create a new project
assert nwGUI.newProject({"projPath": fncProj})
buildTestProject(nwGUI, fncProj)
# Handles for new objects
hNovelRoot = "0000000000008"
+2 -2
View File
@@ -23,7 +23,7 @@ import os
import pytest
from mock import causeOSError
from tools import getGuiItem, readFile, writeFile
from tools import getGuiItem, readFile, writeFile, buildTestProject
from PyQt5.QtWidgets import QAction, QMessageBox, QDialog
@@ -42,7 +42,7 @@ def testDlgSplit_Main(qtbot, monkeypatch, nwGUI, fncProj, mockRnd):
monkeypatch.setattr(QMessageBox, "critical", lambda *a: QMessageBox.Ok)
# Create a new project
assert nwGUI.newProject({"projPath": fncProj}) is True
buildTestProject(nwGUI, fncProj)
# Handles for new objects
hNovelRoot = "0000000000008"
+5 -5
View File
@@ -21,7 +21,7 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
import pytest
from tools import getGuiItem
from tools import getGuiItem, buildTestProject
from PyQt5.QtWidgets import QAction, QDialog, QMessageBox
@@ -48,7 +48,7 @@ def testDlgItemEditor_Dialog(qtbot, monkeypatch, nwGUI, fncProj, mockRnd):
assert nwGUI.editItem() is False
# Create and Open Project
assert nwGUI.newProject({"projPath": fncProj})
buildTestProject(nwGUI, fncProj)
tHandle = "000000000000f"
# No Selection
@@ -99,7 +99,7 @@ def testDlgItemEditor_Novel(qtbot, monkeypatch, nwGUI, fncProj, mockRnd):
monkeypatch.setattr(GuiProjectTree, "hasFocus", lambda *a: True)
# Create Project and Open Document
assert nwGUI.newProject({"projPath": fncProj})
buildTestProject(nwGUI, fncProj)
tHandle = "000000000000f"
assert nwGUI.theProject.statusItems.name(statusKeys[0]) == "New"
@@ -156,7 +156,7 @@ def testDlgItemEditor_Note(qtbot, monkeypatch, nwGUI, fncProj, mockRnd):
monkeypatch.setattr(GuiProjectTree, "hasFocus", lambda *a: True)
# Create Project and Open Document
assert nwGUI.newProject({"projPath": fncProj})
buildTestProject(nwGUI, fncProj)
assert nwGUI.theProject.statusItems.name(statusKeys[0]) == "New"
assert nwGUI.theProject.statusItems.name(statusKeys[1]) == "Note"
assert nwGUI.theProject.importItems.name(importKeys[0]) == "New"
@@ -209,7 +209,7 @@ def testDlgItemEditor_Folder(qtbot, monkeypatch, nwGUI, fncProj, mockRnd):
monkeypatch.setattr(GuiProjectTree, "hasFocus", lambda *a: True)
# Create Project and Open Document
assert nwGUI.newProject({"projPath": fncProj})
buildTestProject(nwGUI, fncProj)
# Edit a Folder
itemEdit = GuiItemEditor(nwGUI, "000000000000d")
+4 -3
View File
@@ -23,7 +23,7 @@ import os
import pytest
from shutil import copyfile
from tools import cmpFiles, getGuiItem
from tools import cmpFiles, getGuiItem, buildTestProject
from PyQt5.QtGui import QColor
from PyQt5.QtCore import Qt
@@ -57,7 +57,7 @@ def testDlgProjSettings_Dialog(
assert getGuiItem("GuiProjectSettings") is None
# Create new project
assert nwGUI.newProject({"projPath": fncProj})
buildTestProject(nwGUI, fncProj)
nwGUI.mainConf.backupPath = fncDir
nwGUI.theProject.setSpellLang("en")
@@ -81,7 +81,7 @@ def testDlgProjSettings_Dialog(
# ============
assert projEdit.tabMain.editName.text() == "New Project"
assert projEdit.tabMain.editTitle.text() == ""
assert projEdit.tabMain.editTitle.text() == "New Novel"
assert projEdit.tabMain.editAuthors.toPlainText() == "Jane Smith\nJohn Smith"
assert projEdit.tabMain.spellLang.currentData() == "en"
assert projEdit.tabMain.doBackup.isChecked() is False
@@ -90,6 +90,7 @@ def testDlgProjSettings_Dialog(
projEdit.tabMain.editName.setText("")
for c in "Project Name":
qtbot.keyClick(projEdit.tabMain.editName, c, delay=typeDelay)
projEdit.tabMain.editTitle.setText("")
for c in "Project Title":
qtbot.keyClick(projEdit.tabMain.editTitle, c, delay=typeDelay)