예제 #1
0
    def test_failing_action(self):
        class FailingTestAction(ResultAction):

            def apply(self, *args, **kwargs):
                raise RuntimeError("YEAH THAT'S A FAILING BEAR")

        ACTIONS.append(FailingTestAction)

        self.section.append(Setting("default_actions",
                                    "YBear: FailingTestAction"))
        ret = autoapply_actions(self.results,
                                {},
                                {},
                                self.section,
                                self.log_printer)
        self.assertEqual(ret, self.results)
        self.assertEqual(self.log_queue.get().message,
                         "Failed to execute action 'FailingTestAction'"
                         " with error: YEAH THAT'S A FAILING BEAR.")
        self.assertIn("YEAH THAT'S A FAILING BEAR",
                      self.log_queue.get().message)
        self.assertEqual(self.log_queue.get().message,
                         "-> for result " + repr(self.resultY) + ".")
        self.assertTrue(self.log_queue.empty())

        ACTIONS.pop()
예제 #2
0
    def test_failing_action(self):
        class FailingTestAction(ResultAction):

            def apply(self, *args, **kwargs):
                raise RuntimeError("YEAH THAT'S A FAILING BEAR")

        ACTIONS.append(FailingTestAction)

        self.section.append(Setting('default_actions',
                                    'YBear: FailingTestAction'))
        ret = autoapply_actions(self.results,
                                {},
                                {},
                                self.section,
                                self.log_printer)
        self.assertEqual(ret, self.results)
        self.assertEqual(self.log_queue.get().message,
                         "Failed to execute action 'FailingTestAction'"
                         " with error: YEAH THAT'S A FAILING BEAR.")
        self.assertIn("YEAH THAT'S A FAILING BEAR",
                      self.log_queue.get().message)
        self.assertEqual(self.log_queue.get().message,
                         '-> for result ' + repr(self.resultY) + '.')
        self.assertTrue(self.log_queue.empty())

        ACTIONS.pop()
예제 #3
0
    def test_applicable_action(self):
        # Use a result whose action can be successfully applied.
        log_printer = self.log_printer

        class TestAction(ResultAction):

            def apply(self, *args, **kwargs):
                log_printer.debug("ACTION APPLIED SUCCESSFULLY.")

        ACTIONS.append(TestAction)

        self.section.append(Setting("default_actions", "Z*: TestAction"))
        ret = autoapply_actions(self.results,
                                {},
                                {},
                                self.section,
                                log_printer)
        self.assertEqual(ret, [self.resultY])
        self.assertEqual(self.log_queue.get().message,
                         "ACTION APPLIED SUCCESSFULLY.")
        self.assertEqual(self.log_queue.get().message,
                         "Applied 'TestAction' "
                         "on the whole project from 'ZBear'.")
        self.assertTrue(self.log_queue.empty())

        ACTIONS.pop()
예제 #4
0
    def test_applicable_action(self):
        # Use a result whose action can be successfully applied.
        log_printer = self.log_printer

        class TestAction(ResultAction):

            def apply(self, *args, **kwargs):
                log_printer.debug('ACTION APPLIED SUCCESSFULLY.')

        ACTIONS.append(TestAction)

        self.section.append(Setting('default_actions', 'Z*: TestAction'))
        ret = autoapply_actions(self.results,
                                {},
                                {},
                                self.section,
                                log_printer)
        self.assertEqual(ret, [self.resultY])
        self.assertEqual(self.log_queue.get().message,
                         'ACTION APPLIED SUCCESSFULLY.')
        self.assertEqual(self.log_queue.get().message,
                         "Applied 'TestAction' "
                         "on the whole project from 'ZBear'.")
        self.assertTrue(self.log_queue.empty())

        ACTIONS.pop()
    def test_failing_action(self):
        class FailingTestAction(ResultAction):

            def apply(self, *args, **kwargs):
                raise RuntimeError("YEAH THAT'S A FAILING BEAR")

        ACTIONS.append(FailingTestAction)

        self.section.append(Setting('default_actions',
                                    'YBear: FailingTestAction'))
        with LogCapture() as capture:
            ret = autoapply_actions(self.results,
                                    {},
                                    {},
                                    self.section,
                                    self.log_printer)
        self.assertEqual(ret, self.results)
        capture.check(
            ('root', 'ERROR', "Failed to execute action 'FailingTestAction' "
             "with error: YEAH THAT'S A FAILING BEAR."),
            ('root', 'INFO', StringComparison(
                r"(?s).*YEAH THAT'S A FAILING BEAR.*")),
            ('root', 'DEBUG', '-> for result ' + repr(self.resultY) + '.')
        )
        ACTIONS.pop()
    def test_applicable_action(self):
        # Use a result whose action can be successfully applied.
        log_printer = self.log_printer

        class TestAction(ResultAction):

            def apply(self, *args, **kwargs):
                logging.debug('ACTION APPLIED SUCCESSFULLY.')

        ACTIONS.append(TestAction)

        self.section.append(Setting('default_actions', 'Z*: TestAction'))
        with LogCapture() as capture:
            ret = autoapply_actions(self.results,
                                    {},
                                    {},
                                    self.section,
                                    log_printer)
        self.assertEqual(ret, [self.resultY])
        capture.check(
            ('root', 'DEBUG', 'ACTION APPLIED SUCCESSFULLY.'),
            ('root', 'INFO', "Applied 'TestAction' on the whole project from "
                             "'ZBear'.")
        )
        ACTIONS.pop()
예제 #7
0
    def test_failing_action(self):
        class FailingTestAction(ResultAction):

            def apply(self, *args, **kwargs):
                raise RuntimeError("YEAH THAT'S A FAILING BEAR")

        ACTIONS.append(FailingTestAction)

        self.section.append(Setting('default_actions',
                                    'YBear: FailingTestAction'))
        with LogCapture() as capture:
            ret = autoapply_actions(self.results,
                                    {},
                                    {},
                                    self.section,
                                    self.log_printer)
        self.assertEqual(ret, self.results)
        capture.check(
            ('root', 'ERROR', "Failed to execute action 'FailingTestAction' "
             "with error: YEAH THAT'S A FAILING BEAR."),
            ('root', 'INFO', StringComparison(
                r"(?s).*YEAH THAT'S A FAILING BEAR.*")),
            ('root', 'DEBUG', '-> for result ' + repr(self.resultY) + '.')
        )
        ACTIONS.pop()
예제 #8
0
    def test_applicable_action(self):
        # Use a result whose action can be successfully applied.
        log_printer = self.log_printer

        class TestAction(ResultAction):

            def apply(self, *args, **kwargs):
                logging.debug('ACTION APPLIED SUCCESSFULLY.')

        ACTIONS.append(TestAction)

        self.section.append(Setting('default_actions', 'Z*: TestAction'))
        with LogCapture() as capture:
            ret = autoapply_actions(self.results,
                                    {},
                                    {},
                                    self.section,
                                    log_printer)
        self.assertEqual(ret, [self.resultY])
        capture.check(
            ('root', 'DEBUG', 'ACTION APPLIED SUCCESSFULLY.'),
            ('root', 'INFO', "Applied 'TestAction' on the whole project from "
                             "'ZBear'.")
        )
        ACTIONS.pop()