blob: 6b49799837790198d1755fd0e89b1f834c37203a (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
|
from PyQt6 import QtCore
import os
from pytest import fixture
from pytestqt import qtbot
from . import getTestDataPath, window
def test_mainwindow_clear(qtbot, window):
"""MainWindow.clear() gives us a clean slate"""
assert len(window.core.selectedComponents) == 0
def test_mainwindow_presetDir_in_tests(qtbot, window):
# FIXME presetDir gets set to projectDir for some reason
assert (
os.path.basename(os.path.dirname(window.core.settings.value("presetDir")))
== "config"
)
def test_mainwindow_openProject(qtbot, window):
"""Open testproject.avp using MainWindow.openProject()"""
window.openProject(getTestDataPath("config/projects/testproject.avp"), prompt=False)
assert len(window.core.selectedComponents) == 2
def test_mainwindow_newProject_without_unsaved_changes(qtbot, window):
"""Starting new project without unsaved changes"""
didCallFunction = False
def captureFunction(*args, **kwargs):
nonlocal didCallFunction
didCallFunction = True
window.createNewProject(prompt=False)
assert not didCallFunction
assert len(window.core.selectedComponents) == 0
def test_mainwindow_newProject_with_unsaved_changes(qtbot, window):
"""Starting new project with unsaved changes"""
didCallFunction = False
def captureFunction(*args, **kwargs):
nonlocal didCallFunction
didCallFunction = True
window.openSaveChangesDialog = captureFunction
window.createNewProject(prompt=True)
assert didCallFunction
|