當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。