def test_deleting_child(): """Test deleting a child. """ root = RootTask() task1 = ComplexTask(name='task1', database_entries={'val1': 2.0}) task2 = SimpleTask(name='task2', database_entries={'val2': 1}, access_exs={'val2': 2}) task3 = ComplexTask(name='task3') task4 = ComplexTask(name='task4') task1.add_child_task(0, task2) task1.add_child_task(1, task4) root.add_child_task(0, task1) root.add_child_task(1, task3) listener = SignalListener() task1.observe('children_changed', listener.listen) task1.remove_child_task(0) assert listener.counter == 1 assert listener.signals[0].removed assert task1.preferences['children_0']['name'] == 'task4' assert 'task2_val2' not in task3.list_accessible_database_entries() root.remove_child_task(0) assert len(root.children) == 1 with pytest.raises(KeyError): root.get_from_database('task1_val1')
def test_moving_child(): """Test moving a child. """ root = RootTask() task1 = ComplexTask(name='task1', database_entries={'val1': 2.0}) task2 = SimpleTask(name='task2', database_entries={'val2': 1}, access_exs={'val2': 2}) task3 = ComplexTask(name='task3') task4 = ComplexTask(name='task4') task1.add_child_task(0, task2) task1.add_child_task(1, task4) root.add_child_task(0, task1) root.add_child_task(1, task3) listener = SignalListener() task1.observe('children_changed', listener.listen) assert task1.preferences['children_0']['name'] == 'task2' assert task1.preferences['children_1']['name'] == 'task4' task1.move_child_task(0, 1) assert listener.counter == 1 assert listener.signals[0].moved assert task1.preferences['children_0']['name'] == 'task4' assert task1.preferences['children_1']['name'] == 'task2' assert task3.get_from_database('task2_val2') == 1
def test_deleting_child(): """Test deleting a child. """ root = RootTask() task1 = ComplexTask(name='task1', database_entries={'val1': 2.0}) task2 = SimpleTask(name='task2', database_entries={'val2': 1}, access_exs={'val2': 2}) task3 = ComplexTask(name='task3') task4 = ComplexTask(name='task4') task1.add_child_task(0, task2) task1.add_child_task(1, task4) root.add_child_task(0, task1) root.add_child_task(1, task3) listener = SignalListener() task1.observe('children_changed', listener.listen) task1.remove_child_task(0) assert task2.parent is None assert task2.root is None assert task2.database is None assert listener.counter == 1 assert listener.signals[0].removed assert task1.preferences['children_0']['name'] == 'task4' assert 'task2_val2' not in task3.list_accessible_database_entries() root.remove_child_task(0) assert task1.parent is None assert task1.root is None assert task1.database is None assert task4.root is None assert task4.database is None assert len(root.children) == 1 with pytest.raises(KeyError): root.get_from_database('task1_val1')