class PrintDebugMessageActionTest(unittest.TestCase):

    def setUp(self):
        self.uut = PrintDebugMessageAction()
        self.test_result = Result('origin', 'message', debug_msg='DEBUG MSG')

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

        self.assertEqual(
            self.uut.is_applicable(Result('o', 'm'), None, None),
            'There is no debug message.'
        )

        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(),
                             self.test_result.debug_msg+'\n')
Exemplo n.º 2
0
class PrintDebugMessageActionTest(unittest.TestCase):
    def setUp(self):
        self.uut = PrintDebugMessageAction()
        self.test_result = Result("origin", "message", debug_msg="DEBUG MSG")

    def test_is_applicable(self):
        self.assertFalse(self.uut.is_applicable(1))
        self.assertFalse(self.uut.is_applicable(Result("o", "m")))
        self.assertTrue(self.uut.is_applicable(self.test_result))

    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(),
                             self.test_result.debug_msg+"\n")
Exemplo n.º 3
0
def provide_all_actions():
    return [
        'Do (N)othing',
        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.º 4
0
class PrintDebugMessageActionTest(unittest.TestCase):

    def setUp(self):
        self.uut = PrintDebugMessageAction()
        self.test_result = Result("origin", "message", debug_msg="DEBUG MSG")

    def test_is_applicable(self):
        self.assertFalse(self.uut.is_applicable(1, None, None))
        self.assertFalse(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(),
                             self.test_result.debug_msg+"\n")
Exemplo n.º 5
0
class PrintDebugMessageActionTest(unittest.TestCase):

    def setUp(self):
        self.uut = PrintDebugMessageAction()
        self.test_result = Result('origin', 'message', debug_msg='DEBUG MSG')

    def test_is_applicable(self):
        self.assertFalse(self.uut.is_applicable(1, None, None))
        self.assertFalse(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(),
                             self.test_result.debug_msg+'\n')
Exemplo n.º 6
0
                         'cannot be printed because it refers to a line '
                         "that doesn't seem to exist in the given file.")
STR_PROJECT_WIDE = 'Project wide:'
STR_ENTER_NUMBER = ('Enter number (Ctrl-'
                    f"{'Z' if platform.system() == 'Windows' else 'D'} "
                    'to exit): ')
STR_INVALID_OPTION = '*** Invalid Option: ({}) ***\n'
WARNING_COLOR = 'red'
FILE_NAME_COLOR = 'blue'
FILE_LINES_COLOR = 'blue'
CAPABILITY_COLOR = 'green'
HIGHLIGHTED_CODE_COLOR = 'red'
SUCCESS_COLOR = 'green'
REQUIRED_SETTINGS_COLOR = 'green'
CLI_ACTIONS = (OpenEditorAction(), ApplyPatchAction(),
               PrintDebugMessageAction(), PrintMoreInfoAction(),
               ShowPatchAction(), IgnoreResultAction(),
               ShowAppliedPatchesAction(), GeneratePatchesAction())
DIFF_EXCERPT_MAX_SIZE = 4


def color_letter(console_printer, line):
    x = line.find('(')
    if x == -1:
        letter = ''
        y = x + 1
    else:
        letter = line[x + 1]
        y = x + 2
    warn = line.rfind('[')
    if warn == 0:
                           'needed by {} for section \"{}\": ')
STR_LINE_DOESNT_EXIST = ('The line belonging to the following result '
                         'cannot be printed because it refers to a line '
                         "that doesn't seem to exist in the given file.")
STR_PROJECT_WIDE = 'Project wide:'
STR_ENTER_NUMBER = 'Enter number (Ctrl-{} to exit): '.format(
    'Z' if platform.system() == 'Windows' else 'D')
FILE_NAME_COLOR = 'blue'
FILE_LINES_COLOR = 'blue'
CAPABILITY_COLOR = 'green'
HIGHLIGHTED_CODE_COLOR = 'red'
SUCCESS_COLOR = 'green'
REQUIRED_SETTINGS_COLOR = 'green'
CLI_ACTIONS = (OpenEditorAction(),
               ApplyPatchAction(),
               PrintDebugMessageAction(),
               PrintMoreInfoAction(),
               ShowPatchAction(),
               IgnoreResultAction(),
               ShowAppliedPatchesAction(),
               GeneratePatchesAction())
DIFF_EXCERPT_MAX_SIZE = 4


def color_letter(console_printer, line):
    x = -1
    y = -1
    letter = ''
    for i, l in enumerate(line, 0):
        if line[i] == '(':
            x = i
Exemplo n.º 8
0
 def setUp(self):
     self.uut = PrintDebugMessageAction()
     self.test_result = Result('origin', 'message', debug_msg='DEBUG MSG')
Exemplo n.º 9
0
 def setUp(self):
     self.uut = PrintDebugMessageAction()
     self.test_result = Result("origin", "message", debug_msg="DEBUG MSG")