class TestLogTask(object):

    def setup(self):
        self.root = RootTask(should_stop=Event(), should_pause=Event())
        self.task = LogTask(task_name='Test')
        self.root.children_task.append(self.task)

    def test_check1(self):
        # Simply test that everything is ok message is evaluable.
        self.task.message = 'True'

        test, traceback = self.task.check()
        assert_true(test)
        assert_false(traceback)

    def test_check2(self):
        # Test handling a wrong message.
        self.task.message = 'True{'

        test, traceback = self.task.check()
        assert_false(test)
        assert_equal(len(traceback), 1)
        assert_in('root/Test', traceback)

    def test_perform(self):
        # Test performing when condition is True.
        self.task.message = 'toro'

        self.root.task_database.prepare_for_running()

        self.task.perform()
        assert_equal(self.root.get_from_database('Test_message'), 'toro')
Exemple #2
0
class TestLogTask(object):
    def setup(self):
        self.root = RootTask(should_stop=Event(), should_pause=Event())
        self.task = LogTask(task_name='Test')
        self.root.children_task.append(self.task)

    def test_check1(self):
        # Simply test that everything is ok message is evaluable.
        self.task.message = 'True'

        test, traceback = self.task.check()
        assert_true(test)
        assert_false(traceback)

    def test_check2(self):
        # Test handling a wrong message.
        self.task.message = 'True{'

        test, traceback = self.task.check()
        assert_false(test)
        assert_equal(len(traceback), 1)
        assert_in('root/Test', traceback)

    def test_perform(self):
        # Test performing when condition is True.
        self.task.message = 'toro'

        self.root.task_database.prepare_for_running()

        self.task.perform()
        assert_equal(self.root.get_from_database('Test_message'), 'toro')
Exemple #3
0
    def setup(self):
        self.workbench = Workbench()
        self.workbench.register(CoreManifest())
        self.workbench.register(StateManifest())
        self.workbench.register(PreferencesManifest())
        self.workbench.register(TaskManagerManifest())

        self.root = RootTask(should_stop=Event(), should_pause=Event())
        self.task = LogTask(task_name='Test', message='rr')
        self.root.children_task.append(self.task)
Exemple #4
0
    def test_collect_dependencies(self):
        # Test collecting build dependencies.
        self.workbench.register(TaskManagerManifest())
        from hqc_meas.tasks.api import RootTask, ComplexTask
        from hqc_meas.tasks.tasks_util.log_task import LogTask
        aux = [LogTask(task_name='r')]
        root = RootTask(task_name='root')
        root.children_task = [
            ComplexTask(task_name='complex', children_task=aux),
            LogTask(task_name='t')
        ]

        core = self.workbench.get_plugin(u'enaml.workbench.core')
        com = u'hqc_meas.dependencies.collect_dependencies'
        res, build, run = core.invoke_command(com, {'obj': root}, core)
        assert_true(res)
        assert_in('tasks', build)
        assert_equal(sorted(['LogTask', 'ComplexTask']),
                     sorted(build['tasks'].keys()))
        assert_not_in('interfaces', build)
        assert_false(run)
    def _create_measure(self, plugin):
        """ Create a measure.

        """
        measure = Measure(plugin=plugin, name='Test1')
        measure.root_task = RootTask(default_path=self.test_dir)
        children = [
            SleepTask(task_name='sleep1', time=1),
            LogTask(task_name='print', message='test'),
            SleepTask(task_name='sleep2', time=0.1)
        ]
        measure.root_task.children_task.extend(children)
        measure.status = 'READY'
        monitor_decl = plugin.monitors[u'monitor1']
        measure.add_monitor(monitor_decl.id,
                            monitor_decl.factory(monitor_decl, self.workbench))
        return measure
 def setup(self):
     self.root = RootTask(should_stop=Event(), should_pause=Event())
     self.task = LogTask(task_name='Test')
     self.root.children_task.append(self.task)
Exemple #7
0
 def setup(self):
     self.root = RootTask(should_stop=Event(), should_pause=Event())
     self.task = LogTask(task_name='Test')
     self.root.children_task.append(self.task)