当前位置: 首页>>代码示例>>Python>>正文


Python base_tasks.RootTask类代码示例

本文整理汇总了Python中ecpy.tasks.base_tasks.RootTask的典型用法代码示例。如果您正苦于以下问题:Python RootTask类的具体用法?Python RootTask怎么用?Python RootTask使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了RootTask类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: setup

 def setup(self):
     root = RootTask()
     root.should_pause = Event()
     root.should_stop = Event()
     root.paused = Event()
     root.default_path = 'toto'
     self.root = root
开发者ID:pombredanne,项目名称:ecpy,代码行数:7,代码来源:test_execution.py

示例2: test_database_update_with_exception

def test_database_update_with_exception():
    """Test that replacing the database_entries members refreshes the database.

    """
    root = RootTask()
    task1 = ComplexTask(name='task1',
                        database_entries={'val1': 2.0})
    task2 = SimpleTask(name='task2',
                       database_entries={'val2': 1},
                       access_exs={'val2': 1})
    task3 = ComplexTask(name='task3')
    task1.add_child_task(0, task2)
    root.add_child_task(0, task1)
    root.add_child_task(1, task3)

    assert task3.get_from_database('task2_val2')

    entries = task2.database_entries.copy()
    del entries['val2']
    task2.database_entries = entries

    with pytest.raises(KeyError):
        task1.get_from_database('task2_val2')

    with pytest.raises(KeyError):
        task3.get_from_database('task2_val2')
开发者ID:pombredanne,项目名称:ecpy,代码行数:26,代码来源:test_base_tasks.py

示例3: test_moving_child

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
开发者ID:pombredanne,项目名称:ecpy,代码行数:32,代码来源:test_base_tasks.py

示例4: test_saving_building_from_config

    def test_saving_building_from_config(self, iterable_interface):
        """Done here as the LoopTask is a viable case of a member tagged with
        child.

        """
        subtask1 = CheckTask(name='check', database_entries={'val': 1})
        self.task.task = subtask1

        self.root.update_preferences_from_members()

        deps = {'ecpy.task': {'ecpy.RootTask': RootTask,
                              'ecpy.LoopTask': LoopTask,
                              'ecpy.CheckTask': CheckTask}
                }
        new = RootTask.build_from_config(self.root.preferences, deps)

        assert new.children[0].task.name == 'check'

        self.task.interface = iterable_interface
        self.root.update_preferences_from_members()
        prefs = self.root.preferences
        del prefs['children_0']['task']
        deps = {'ecpy.task': {'ecpy.RootTask': RootTask,
                              'ecpy.LoopTask': LoopTask,
                              'ecpy.CheckTask': CheckTask},
                'ecpy.tasks.interface':
                    {('IterableLoopInterface', ('ecpy.LoopTask',)):
                        IterableLoopInterface}
                }
        new = RootTask.build_from_config(prefs, deps)

        assert not new.children[0].task
开发者ID:MatthieuDartiailh,项目名称:ecpy,代码行数:32,代码来源:test_loop_task.py

示例5: test_access_exceptions

def test_access_exceptions():
    """Test adding, modifying and removing an access exception after creation.

    """
    root = RootTask()
    listener = SignalListener()
    root.observe('children_changed', listener.listen)
    task1 = ComplexTask(name='task1',
                        database_entries={'val1': 2.0})
    task2 = ComplexTask(name='task2')
    task3 = SimpleTask(name='task3',
                       database_entries={'val2': 1},
                       )

    task2.add_child_task(0, task3)
    task1.add_child_task(0, task2)
    root.add_child_task(0, task1)

    with pytest.raises(KeyError):
        task2.get_from_database('task3_val2')

    task3.add_access_exception('val2', 1)

    assert task2.get_from_database('task3_val2') == 1
    with pytest.raises(KeyError):
        task1.get_from_database('task3_val2')

    task3.modify_access_exception('val2', 2)
    assert task1.get_from_database('task3_val2') == 1

    task3.remove_access_exception('val2')
    with pytest.raises(KeyError):
        task2.get_from_database('task3_val2')
开发者ID:pombredanne,项目名称:ecpy,代码行数:33,代码来源:test_base_tasks.py

示例6: test_saving_building_from_config

    def test_saving_building_from_config(self):
        """Done here as the LoopTask is a viable case of a member tagged with
        child.

        """
        subtask1 = CheckTask(name='check', database_entries={'val': 1})
        self.task.task = subtask1

        self.root.update_preferences_from_members()

        new = RootTask.build_from_config(self.root.preferences,
                                         {'ecpy.task': {'RootTask': RootTask,
                                                        'LoopTask': LoopTask,
                                                        'CheckTask': CheckTask}
                                          })

        assert new.children[0].task.name == 'check'

        self.root.update_preferences_from_members()
        prefs = self.root.preferences
        del prefs['children_0']['task']
        new = RootTask.build_from_config(prefs,
                                         {'ecpy.task': {'RootTask': RootTask,
                                                        'LoopTask': LoopTask,
                                                        'CheckTask': CheckTask}
                                          })

        assert not new.children[0].task
开发者ID:pombredanne,项目名称:ecpy,代码行数:28,代码来源:test_loop_task.py

示例7: test_task_renaming

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
开发者ID:pombredanne,项目名称:ecpy,代码行数:26,代码来源:test_base_tasks.py

示例8: test_build_from_config1

    def test_build_from_config1(self):
        """Test building a interfaceable task with no interface from a config.

        """
        aux = RootTask()
        aux.add_child_task(0, IMixin())
        print(aux.preferences)
        bis = RootTask.build_from_config(aux.preferences,
                                         {'ecpy.task': {'IMixin': IMixin,
                                                        'RootTask': RootTask}})
        assert type(bis.children[0]).__name__ == 'IMixin'
开发者ID:pombredanne,项目名称:ecpy,代码行数:11,代码来源:test_task_interfaces.py

示例9: test_database_update

def test_database_update():
    """Test that replacing the database_entries members refreshes the database.

    """
    root = RootTask()
    entries = root.database_entries.copy()
    del entries['meas_name']
    entries['name'] = 'Test'
    root.database_entries = entries

    assert root.get_from_database('name') == 'Test'
    with pytest.raises(KeyError):
        root.get_from_database('meas_name')
开发者ID:pombredanne,项目名称:ecpy,代码行数:13,代码来源:test_base_tasks.py

示例10: test_build_from_config1

    def test_build_from_config1(self):
        """Test building a interfaceable interface with no interface from a
        config.

        """
        aux = RootTask()
        mixin = Mixin()
        mixin.interface = InterfaceTest3()
        aux.add_child_task(0, mixin)
        deps = {'ecpy.task': {'tests.Mixin': Mixin, 'ecpy.RootTask': RootTask},
                'ecpy.tasks.interface':
                    {('InterfaceTest3', ('tests.Mixin',)): InterfaceTest3}}
        bis = RootTask.build_from_config(aux.preferences, deps)
        assert type(bis.children[0].interface).__name__ == 'InterfaceTest3'
开发者ID:MatthieuDartiailh,项目名称:ecpy,代码行数:14,代码来源:test_task_interfaces.py

示例11: setup

 def setup(self):
     self.root = RootTask()
     database = self.root.database
     database.set_value('root', 'val1', 1)
     database.create_node('root', 'node1')
     database.set_value('root/node1', 'val2', 10.0)
     database.add_access_exception('root', 'root/node1', 'val2')
开发者ID:MatthieuDartiailh,项目名称:ecpy,代码行数:7,代码来源:test_string_ops.py

示例12: test_database_operation

def test_database_operation():
    """Test setting, getting, deleting a value from the database.

    """
    root = RootTask()
    root.write_in_database('test', 1)
    assert root.get_from_database('test') == 1
    root.remove_from_database('test')
    with pytest.raises(KeyError):
        root.get_from_database('test')
开发者ID:pombredanne,项目名称:ecpy,代码行数:10,代码来源:test_base_tasks.py

示例13: test_deleting_child

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')
开发者ID:pombredanne,项目名称:ecpy,代码行数:34,代码来源:test_base_tasks.py

示例14: test_update_preferences_from_members

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'
开发者ID:pombredanne,项目名称:ecpy,代码行数:19,代码来源:test_base_tasks.py

示例15: test_root_registering

def test_root_registering():
    """Check that the root task does write its default entries in the database
    when instantiated.

    """
    root = RootTask()
    assert root.get_from_database('default_path') == ''
    assert root.get_from_database('meas_name') == ''
    assert root.get_from_database('meas_id') == ''
    assert root.get_from_database('meas_date') == ''
    root.children = [SimpleTask(name='task2',
                                database_entries={'val2': 1},
                                root=root, parent=root,
                                database=root.database)]
    root.register_in_database()
    assert root.get_from_database('task2_val2') == 1
开发者ID:pombredanne,项目名称:ecpy,代码行数:16,代码来源:test_base_tasks.py


注:本文中的ecpy.tasks.base_tasks.RootTask类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。