@@ 544-569 (lines=26) @@ | ||
541 | class TestAction(ResultAction): |
|
542 | ||
543 | def apply(self, *args, **kwargs): |
|
544 | log_printer.debug("ACTION APPLIED SUCCESSFULLY.") |
|
545 | ||
546 | ACTIONS.append(TestAction) |
|
547 | ||
548 | self.section.append(Setting("default_actions", "Z*: TestAction")) |
|
549 | ret = autoapply_actions(self.results, |
|
550 | {}, |
|
551 | {}, |
|
552 | self.section, |
|
553 | log_printer) |
|
554 | self.assertEqual(ret, [self.resultY]) |
|
555 | self.assertEqual(self.log_queue.get().message, |
|
556 | "ACTION APPLIED SUCCESSFULLY.") |
|
557 | self.assertEqual(self.log_queue.get().message, |
|
558 | "Applied 'TestAction' " |
|
559 | "on the whole project from 'ZBear'.") |
|
560 | self.assertTrue(self.log_queue.empty()) |
|
561 | ||
562 | ACTIONS.pop() |
|
563 | ||
564 | def test_failing_action(self): |
|
565 | class FailingTestAction(ResultAction): |
|
566 | ||
567 | def apply(self, *args, **kwargs): |
|
568 | raise RuntimeError("YEAH THAT'S A FAILING BEAR") |
|
569 | ||
570 | ACTIONS.append(FailingTestAction) |
|
571 | ||
572 | self.section.append(Setting("default_actions", |
|
@@ 517-542 (lines=26) @@ | ||
514 | ||
515 | def test_without_default_action_and_unapplicable(self): |
|
516 | # Use a result where no default action is supplied for and another one |
|
517 | # where the action is not applicable. |
|
518 | old_is_applicable = ApplyPatchAction.is_applicable |
|
519 | ApplyPatchAction.is_applicable = lambda *args: False |
|
520 | ||
521 | self.section.append(Setting( |
|
522 | "default_actions", |
|
523 | "NoBear: ApplyPatchAction, YBear: ApplyPatchAction")) |
|
524 | ret = autoapply_actions(self.results, |
|
525 | {}, |
|
526 | {}, |
|
527 | self.section, |
|
528 | self.log_printer) |
|
529 | self.assertEqual(ret, self.results) |
|
530 | self.assertEqual(self.log_queue.get().message, |
|
531 | "Selected default action 'ApplyPatchAction' for bear " |
|
532 | "'YBear' is not applicable. Action not applied.") |
|
533 | self.assertTrue(self.log_queue.empty()) |
|
534 | ||
535 | ApplyPatchAction.is_applicable = old_is_applicable |
|
536 | ||
537 | def test_applicable_action(self): |
|
538 | # Use a result whose action can be successfully applied. |
|
539 | log_printer = self.log_printer |
|
540 | ||
541 | class TestAction(ResultAction): |
|
542 | ||
543 | def apply(self, *args, **kwargs): |
|
544 | log_printer.debug("ACTION APPLIED SUCCESSFULLY.") |
|
545 |