def test_perform1(self): # Test performing a simple loop no timing. Iterable interface. interface = IterableLoopInterface() interface.iterable = 'range(11)' self.task.interface = interface self.root.task_database.prepare_for_running() self.task.perform() assert_equal(self.root.get_from_database('Test_value'), 10)
def test_check_iterable_interface1(self): # Simply test that everything is ok when all formulas are true. interface = IterableLoopInterface() interface.iterable = 'range(11)' self.task.interface = interface test, traceback = self.task.check() assert_true(test) assert_false(traceback) assert_equal(self.task.get_from_database('Test_point_number'), 11)
def test_check_iterable_interface3(self): # Test handling a wrong iterable type. interface = IterableLoopInterface() interface.iterable = '1.0' self.task.interface = interface test, traceback = self.task.check() assert_false(test) assert_equal(len(traceback), 1) assert_in('root/Test', traceback)
def test_check_execution_order(self): # Test that the interface checks are run before the children checks. interface = IterableLoopInterface() interface.iterable = '[(1, 0)]' self.task.interface = interface subiter = IterableLoopInterface(iterable='{Test_value}') self.task.children_task = [LoopTask(interface=subiter)] test, traceback = self.task.check() assert_true(test)
def test_perform_task1(self): # Test performing a loop with an embedded task no timing. interface = IterableLoopInterface() interface.iterable = 'range(11)' self.task.interface = interface self.task.task = CheckTask(task_name='check') self.root.task_database.prepare_for_running() self.task.perform() assert_equal(self.root.get_from_database('Test_index'), 11) assert_true(self.task.task.perform_called) assert_equal(self.task.task.perform_value, 10)
def test_perform3(self): # Test performing a simple loop no timing. Break. interface = IterableLoopInterface() interface.iterable = 'range(11)' self.task.interface = interface self.task.children_task.append(BreakTask(task_name='break', condition='{Test_value} == 5') ) self.root.task_database.prepare_for_running() self.task.perform() assert_equal(self.root.get_from_database('Test_value'), 5)
def test_perform4(self): # Test performing a simple loop no timing. Continue interface = IterableLoopInterface() interface.iterable = 'range(11)' self.task.interface = interface self.task.children_task.append(ContinueTask(task_name='break', condition='True') ) self.task.children_task.append(CheckTask(task_name='check')) self.root.task_database.prepare_for_running() self.task.perform() assert_false(self.task.children_task[1].perform_called)
def test_perform_task2(self): # Test performing a loop with an embedded task no timing. Break. interface = IterableLoopInterface() interface.iterable = 'range(11)' self.task.interface = interface self.task.task = CheckTask(task_name='check') self.task.children_task.append(BreakTask(task_name='break', condition='{Test_index} == 6') ) self.root.task_database.prepare_for_running() self.task.perform() assert_equal(self.root.get_from_database('Test_index'), 6) assert_true(self.task.task.perform_called) assert_equal(self.task.task.perform_value, 5)
def test_check_iterable_interface1(self): # Simply test that everything is ok when all formulas are true. interface = IterableLoopInterface() interface.iterable = 'range(11)' self.task.interface = interface test, traceback = self.task.check() assert_true(test) assert_false(traceback) assert_equal(self.task.get_from_database('Test_point_number'), 11) interface.iterable = 'dict(a=1)' test, traceback = self.task.check() assert_true(test) assert_false(traceback) assert_equal(self.task.get_from_database('Test_point_number'), 1) assert_equal(self.task.get_from_database('Test_value'), 'a')
def test_perform_timing_task3(self): # Test performing a loop with an embedded task no timing. Continue. interface = IterableLoopInterface() interface.iterable = 'range(11)' self.task.interface = interface self.task.timing = True self.task.task = CheckTask(task_name='check') self.task.children_task.append(ContinueTask(task_name='break', condition='True') ) self.task.children_task.append(CheckTask(task_name='check')) self.root.task_database.prepare_for_running() self.task.perform() assert_equal(self.root.get_from_database('Test_index'), 11) assert_true(self.task.task.perform_called) assert_equal(self.task.task.perform_value, 10) assert_false(self.task.children_task[1].perform_called) assert_not_equal(self.root.get_from_database('Test_elapsed_time'), 1.0)