class TaskEngineTest(unittest.TestCase): def setUp(self): self.cli = FakeCli() self.e = TaskEngine(self.cli) def test_can_add_tasks(self): self.e.addTask(Task("T1")) self.e.addTask(Task("T2")) def test_run(self): self.e.addTask(Task("T1")) self.e.addTask(Task("T2")) self.e.run() def test_failure(self): task1 = MockTask("T1") failingTask = MockTask("T2") failingTask.failed = True task3 = MockTask("T3") self.e.addTask(task1) self.e.addTask(failingTask) self.e.run() self.assertTrue(task1.executed) self.assertTrue(failingTask.executed) self.assertFalse(task3.executed) def test_addTask_count_tasks(self): self.e.addTask(MockTask("T1")) self.e.addTask(MockTask("T2")) self.e.addTask(MockTask("T3")) self.assertEquals(3, self.e.taskToRun())
def setUp(self): self.cli = FakeCli() self.e = TaskEngine(self.cli)
def resolve(defectId): model = TasksModel() rally = RallyService() #for iter in rally.getCurrentIterations(): # if hasattr(iter, 'Name'): # print iter #sys.exit(0) cdets = CdetsService() validate = ValidateDefect("Validate defect in Rally and CDEST", rally, cdets, model) collect = CollectParameters("Collect CDETS Defect parameters", cdets, model) moveToR = MoveToR("Move to R the CDETS Defect", cdets, model) moveToA = MoveToA("Move to A the Rally Defect", rally, model) engine = TaskEngine(SimpleCli()) if not defectId: engine.addTask( SelectDefect("Select the defect to move to A", rally, model)) else: model.id = defectId[2:] engine.addTask(validate) engine.addTask(collect) engine.addTask(moveToR) engine.addTask(moveToA) engine.run()