Esempio n. 1
0
def test_save_as_does_nothing_if_no_project_set(qtbot, monkeypatch):
    """ When saving, the signal is raised """
    # Given
    manager = ProjectFileManager()
    qtbot.add_widget(manager)
    monkeypatch.delattr(QFileDialog, "getSaveFileName")

    # When
    manager.save_project_as()

    # Then
    assert manager.project is None
Esempio n. 2
0
def test_save_as_changes_filename(qtbot, tmpdir, monkeypatch):
    """ When saving, the signal is raised """
    # Given
    filename = tmpdir.join("test_save_resets_need_saving.txt")
    manager = ProjectFileManager()
    qtbot.add_widget(manager)
    project = ResearchProject("")
    manager.project = project

    monkeypatch.setattr(QFileDialog, "getSaveFileName",
                        lambda _, __, ___, ____: (str(filename), True))

    # When
    manager.save_project_as()

    # Then
    assert manager.project.filename == str(filename)
Esempio n. 3
0
def test_save_as_aborts_on_empty_filename(qtbot, monkeypatch):
    """ When saving, the signal is raised """
    # Given
    filename = "Foo"
    manager = ProjectFileManager()
    qtbot.add_widget(manager)
    project = ResearchProject(filename)
    manager.project = project

    monkeypatch.setattr(QFileDialog, "getSaveFileName",
                        lambda _, __, ___, ____: ("", True))

    # When
    with qtbot.assertNotEmitted(manager.project_saved):
        manager.save_project_as()

    # Then
    assert manager.project.filename == filename