def test_delete_calls_signals(qtbot): """ The start and end row removal signals should be emitted """ # Given model = TreeModel() project = ResearchProject("") plan = ResearchPlan() project.plans.append(plan) model.set_project(project) plan_index = model.index(0, 0, model.plans_index) # When with qtbot.waitSignals([model.rowsAboutToBeRemoved, model.rowsRemoved]): model.delete_node(plan_index)
def test_delete_does_nothing_on_invalid_index(qtbot): """ Delete removes task from underlying data structure """ # Given model = TreeModel() project = ResearchProject("") project.add_plan().add_task() model.set_project(project) # When with qtbot.assertNotEmitted(model.rowsAboutToBeRemoved): with qtbot.assertNotEmitted(model.rowsRemoved): model.delete_node(QModelIndex()) # Then assert len(project.plans) == 1 assert len(project.plans[0].tasks) == 1
def test_delete_removes_plan(): """ Delete removes plan from underlying data structure """ # Given model = TreeModel() project = ResearchProject("") plan = ResearchPlan() task = ResearchTask() plan.tasks.append(task) project.plans.append(plan) model.set_project(project) plan_index = model.index(0, 0, model.plans_index) # When model.delete_node(plan_index) # Then assert len(project.plans) == 0