Exemple #1
0
    def test_build_from_config2(self):
        """Test building a interfaceable interface with an interface from a
        config.

        """
        self.mixin.interface = IIinterfaceTest1(answer=True)
        self.root.update_preferences_from_members()
        deps = {
            'exopy.task': {
                'tasks.Mixin': Mixin,
                'exopy.RootTask': RootTask
            },
            'exopy.tasks.interface': {
                'tasks.Mixin:tasks.InterfaceTest3':
                InterfaceTest3,
                'tasks.Mixin:tasks.InterfaceTest3:tasks.IIinterfaceTest1':
                IIinterfaceTest1
            }
        }
        bis = RootTask.build_from_config(self.root.preferences, deps)

        interface = bis.children[0].interface.interface
        assert type(interface).__name__ == 'IIinterfaceTest1'
        assert self.root.children[0].database_entries ==\
            {'test': 2.0, 'itest': 1.0}
Exemple #2
0
def test_build_root_from_config():
    """Test building a RootTask from config.

    """
    class DummyTask(SimpleTask):

        database_entries = {'test': 1}

    config = {
        'name': 'test',
        'children_0': {
            'name': 'test_child',
            'task_id': 'DummyTask'
        }
    }
    task = RootTask.build_from_config(config,
                                      {'exopy.task': {
                                          'DummyTask': DummyTask
                                      }})
    assert task.name == 'Root'
    assert len(task.children) == 1
    assert task.children[0].name == 'test_child'
    assert task.children[0].root
    assert isinstance(task.children[0], DummyTask)
    assert task.get_from_database('test_child_test')
Exemple #3
0
    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())

        bis = RootTask.build_from_config(aux.preferences,
                                         {'exopy.task':
                                             {'tasks.IMixin': IMixin,
                                              'exopy.RootTask': RootTask}})
        assert type(bis.children[0]).__name__ == 'IMixin'
Exemple #4
0
    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())

        bis = RootTask.build_from_config(aux.preferences,
                                         {'exopy.task':
                                             {'tasks.IMixin': IMixin,
                                              'exopy.RootTask': RootTask}})
        assert type(bis.children[0]).__name__ == 'IMixin'
Exemple #5
0
    def test_build_from_config2(self):
        """Test building a interfaceable task with an interface from a config.

        """
        self.mixin.interface = InterfaceTest(answer=True)
        self.root.update_preferences_from_members()
        deps = {'exopy.task': {'tasks.Mixin': Mixin,
                               'exopy.RootTask': RootTask},
                'exopy.tasks.interface':
                    {'tasks.Mixin:tasks.InterfaceTest': InterfaceTest}}
        bis = RootTask.build_from_config(self.root.preferences, deps)

        assert type(bis.children[0].interface).__name__ == 'InterfaceTest'
Exemple #6
0
    def test_build_from_config2(self):
        """Test building a interfaceable task with an interface from a config.

        """
        self.mixin.interface = InterfaceTest(answer=True)
        self.root.update_preferences_from_members()
        deps = {'exopy.task': {'tasks.Mixin': Mixin,
                               'exopy.RootTask': RootTask},
                'exopy.tasks.interface':
                    {'tasks.Mixin:tasks.InterfaceTest': InterfaceTest}}
        bis = RootTask.build_from_config(self.root.preferences, deps)

        assert type(bis.children[0].interface).__name__ == 'InterfaceTest'
Exemple #7
0
    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 = {'exopy.task': {'tasks.Mixin': Mixin,
                               'exopy.RootTask': RootTask},
                'exopy.tasks.interface':
                    {'tasks.Mixin:tasks.InterfaceTest3': InterfaceTest3}}
        bis = RootTask.build_from_config(aux.preferences, deps)
        assert type(bis.children[0].interface).__name__ == 'InterfaceTest3'
Exemple #8
0
    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 = {'exopy.task': {'tasks.Mixin': Mixin,
                               'exopy.RootTask': RootTask},
                'exopy.tasks.interface':
                    {'tasks.Mixin:tasks.InterfaceTest3': InterfaceTest3}}
        bis = RootTask.build_from_config(aux.preferences, deps)
        assert type(bis.children[0].interface).__name__ == 'InterfaceTest3'
Exemple #9
0
def test_build_root_from_config():
    """Test building a RootTask from config.

    """
    class DummyTask(SimpleTask):

        database_entries = {'test': 1}

    config = {'name': 'test',
              'children_0': {'name': 'test_child',
                             'task_id': 'DummyTask'}}
    task = RootTask.build_from_config(config,
                                      {'exopy.task':
                                          {'DummyTask': DummyTask}})
    assert task.name == 'Root'
    assert len(task.children) == 1
    assert task.children[0].name == 'test_child'
    assert task.children[0].root
    assert isinstance(task.children[0], DummyTask)
    assert task.get_from_database('test_child_test')
Exemple #10
0
    def test_build_from_config2(self):
        """Test building a interfaceable interface with an interface from a
        config.

        """
        self.mixin.interface = IIinterfaceTest1(answer=True)
        self.root.update_preferences_from_members()
        deps = {'exopy.task': {'tasks.Mixin': Mixin,
                               'exopy.RootTask': RootTask},
                'exopy.tasks.interface':
                    {'tasks.Mixin:tasks.InterfaceTest3': InterfaceTest3,
                     'tasks.Mixin:tasks.InterfaceTest3:tasks.IIinterfaceTest1':
                         IIinterfaceTest1
                     }
                }
        bis = RootTask.build_from_config(self.root.preferences, deps)

        interface = bis.children[0].interface.interface
        assert type(interface).__name__ == 'IIinterfaceTest1'
        assert self.root.children[0].database_entries ==\
            {'test': 2.0, 'itest': 1.0}