def setUp(self):
        self.uut = PrintAspectAction()

        @Root.subaspect
        class test_aspect:
            """
            This is a test aspect
            """
            class docs:
                example = 'test'
                example_language = 'test'
                importance_reason = 'test'
                fix_suggestions = 'test'

        self.test_aspect = test_aspect('py')
        self.test_result = Result('origin', 'message', aspect=self.test_aspect)
Exemplo n.º 2
0
def provide_all_actions():
    return [DoNothingAction().get_metadata().desc,
            ShowPatchAction().get_metadata().desc,
            ApplyPatchAction().get_metadata().desc,
            IgnoreResultAction().get_metadata().desc,
            OpenEditorAction().get_metadata().desc,
            PrintAspectAction().get_metadata().desc,
            PrintDebugMessageAction().get_metadata().desc,
            PrintMoreInfoAction().get_metadata().desc]
Exemplo n.º 3
0
class PrintAspectActionTest(unittest.TestCase):

    def setUp(self):
        self.uut = PrintAspectAction()

        @Root.subaspect
        class test_aspect:
            """
            This is a test aspect
            """
            class docs:
                example = 'test'
                example_language = 'test'
                importance_reason = 'test'
                fix_suggestions = 'test'

        self.test_aspect = test_aspect('py')
        self.test_result = Result('origin', 'message', aspect=self.test_aspect)

    def test_is_applicable(self):
        with self.assertRaises(TypeError):
            self.uut.is_applicable(1, None, None)

        self.assertEqual(
            'There is no aspect associated with the result.',
            self.uut.is_applicable(Result('o', 'm'), None, None))

        self.assertTrue(self.uut.is_applicable(self.test_result, None, None))

    def test_apply(self):
        with retrieve_stdout() as stdout:
            self.assertEqual(self.uut.apply_from_section(self.test_result,
                                                         {},
                                                         {},
                                                         Section('name')),
                             {})
            self.assertEqual(stdout.getvalue(),
                             type(self.test_aspect).__qualname__ + '\n' +
                             type(self.test_aspect).docs.definition + '\n')
class PrintAspectActionTest(unittest.TestCase):
    def setUp(self):
        self.uut = PrintAspectAction()

        @Root.subaspect
        class test_aspect:
            """
            This is a test aspect
            """
            class docs:
                example = 'test'
                example_language = 'test'
                importance_reason = 'test'
                fix_suggestions = 'test'

        self.test_aspect = test_aspect('py')
        self.test_result = Result('origin', 'message', aspect=self.test_aspect)

    def test_is_applicable(self):
        with self.assertRaises(TypeError):
            self.uut.is_applicable(1, None, None)

        self.assertEqual('There is no aspect associated with the result.',
                         self.uut.is_applicable(Result('o', 'm'), None, None))

        self.assertTrue(self.uut.is_applicable(self.test_result, None, None))

    def test_apply(self):
        with retrieve_stdout() as stdout:
            self.assertEqual(
                self.uut.apply_from_section(self.test_result, {}, {},
                                            Section('name')), {})
            self.assertEqual(
                stdout.getvalue(),
                type(self.test_aspect).__qualname__ + '\n' +
                type(self.test_aspect).docs.definition + '\n')
Exemplo n.º 5
0
    def setUp(self):
        self.uut = PrintAspectAction()

        @Root.subaspect
        class test_aspect:
            """
            This is a test aspect
            """
            class docs:
                example = 'test'
                example_language = 'test'
                importance_reason = 'test'
                fix_suggestions = 'test'

        self.test_aspect = test_aspect('py')
        self.test_result = Result('origin', 'message', aspect=self.test_aspect)