class TestWhileTask(object):

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

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

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

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

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

    def test_perform1(self):
        # Test performing when condition is True.
        self.task.condition = '{Test_index} < 5'

        self.root.task_database.prepare_for_running()

        self.task.perform()
        assert_equal(self.check.perform_called, 4)

    def test_perform2(self):
        # Test performing when condition is False.
        self.task.condition = '1 < 0'

        self.root.task_database.prepare_for_running()

        self.task.perform()
        assert_false(self.check.perform_called)

    def test_perform3(self):
        # Test performing when condition is True. Stop event set.
        self.root.should_stop.set()
        self.task.condition = '{Test_index} < 5'

        self.root.task_database.prepare_for_running()

        self.task.perform()
        assert_equal(self.check.perform_called, 0)
Exemple #2
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 = WhileTask(task_name='Test', condition='rr')
        self.root.children_task.append(self.task)
Exemple #3
0
class TestWhileTask(object):
    def setup(self):
        self.root = RootTask(should_stop=Event(), should_pause=Event())
        self.task = WhileTask(task_name='Test')
        self.root.children_task.append(self.task)
        self.check = CheckTask(task_name='check')
        self.task.children_task.append(self.check)

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

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

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

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

    def test_perform1(self):
        # Test performing when condition is True.
        self.task.condition = '{Test_index} < 5'

        self.root.task_database.prepare_for_running()

        self.task.perform()
        assert_equal(self.check.perform_called, 4)

    def test_perform2(self):
        # Test performing when condition is False.
        self.task.condition = '1 < 0'

        self.root.task_database.prepare_for_running()

        self.task.perform()
        assert_false(self.check.perform_called)

    def test_perform3(self):
        # Test performing when condition is True. Stop event set.
        self.root.should_stop.set()
        self.task.condition = '{Test_index} < 5'

        self.root.task_database.prepare_for_running()

        self.task.perform()
        assert_equal(self.check.perform_called, 0)
    def test_check2(self):
        # Simply test that everything is ok condition is evaluable and parent
        # is a While.
        whil = WhileTask(children_task=[self.task])
        self.root.children_task.append(whil)
        self.task.condition = 'True'

        test, traceback = self.task.check()
        assert_true(test)
        assert_false(traceback)
 def setup(self):
     self.root = RootTask(should_stop=Event(), should_pause=Event())
     self.task = WhileTask(task_name='Test')
     self.root.children_task.append(self.task)
     self.check = CheckTask(task_name='check')
     self.task.children_task.append(self.check)
Exemple #6
0
 def setup(self):
     self.root = RootTask(should_stop=Event(), should_pause=Event())
     self.task = WhileTask(task_name='Test')
     self.root.children_task.append(self.task)
     self.check = CheckTask(task_name='check')
     self.task.children_task.append(self.check)