def test_task_renaming(): """Test renaming simple and complex task. """ root = RootTask() task1 = ComplexTask(name='task1', database_entries={'val1': 2.0}) task2 = ComplexTask(name='task2') task3 = SimpleTask(name='task3', database_entries={'val2': 1}, access_exs={'val2': 2}) task2.add_child_task(0, task3) task1.add_child_task(0, task2) root.add_child_task(0, task1) task3.name = 'worker3' with pytest.raises(KeyError): root.get_from_database('task3_val2') assert root.get_from_database('worker3_val2') == 1 task1.name = 'worker1' with pytest.raises(KeyError): root.get_from_database('task1_val1') assert root.get_from_database('worker1_val1') == 2.0 assert root.get_from_database('worker3_val2') == 1
def test_update_preferences_from_members(): """Test updating the preferences. Only operation on the children cause re-registering to ensure the children ordering. """ root = RootTask() task1 = SimpleTask(name='task1') root.add_child_task(0, task1) assert root.preferences['children_0']['name'] == 'task1' task1.name = 'worker1' assert root.preferences['children_0']['name'] == 'task1' root.update_preferences_from_members() assert root.preferences['children_0']['name'] == 'worker1'