def test_unlink_gedcom_does_nothing_if_no_project_set(qtbot): """ If the project is None, no gedcom link should be removed """ # Given manager = ProjectFileManager() # monkeypatch.delattr(manager.gedcom_discard, "exec_") # when with qtbot.assertNotEmitted(manager.project_changed): manager.unlink_gedcom_file() # Then assert manager.project is None
def test_unlink_gedcom_does_nothing_if_no_gedcom_link_set(qtbot): """ If there is no gedcom link, nothing should happen """ # Given manager = ProjectFileManager() manager.project = ResearchProject("") # monkeypatch.delattr(manager.gedcom_discard, "exec_") # when with qtbot.assertNotEmitted(manager.project_changed): manager.unlink_gedcom_file() # Then assert manager.project.gedcom == ""
def test_unlink_discard_cancel_makes_no_change(monkeypatch, qtbot): """ When a link exists and the confirmation dialog cancels, nothing should happen """ # Given manager = ProjectFileManager() manager.project = ResearchProject("") manager.project.gedcom = "Foo" monkeypatch.setattr(manager.gedcom_discard, "exec_", lambda: QMessageBox.Cancel) # when with qtbot.assertNotEmitted(manager.project_changed): manager.unlink_gedcom_file() # Then assert manager.project.gedcom == "Foo"
def test_unlink_discard_ok_removes_link(monkeypatch, qtbot): """ When a link exists and the confirmation dialog accepted, the link is removed """ # Given manager = ProjectFileManager() manager.project = ResearchProject("") manager.project.gedcom = "Foo" monkeypatch.setattr(manager.gedcom_discard, "exec_", lambda: QMessageBox.Ok) # when with qtbot.waitSignals([manager.project_changed]): manager.unlink_gedcom_file() # Then assert manager.project.gedcom == "" assert manager.needs_saving is True