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')
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')