aboutsummaryrefslogtreecommitdiff
path: root/tests/test_mainwindow_projects.py
blob: 8ad491a662dc2ae82291c4f5f95ee0ccea3d8c56 (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
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_openProject(qtbot, window):
    """Open testproject.avp using MainWindow.openProject()"""
    window.openProject(getTestDataPath("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