예제 #1
0
    def test_validation_fails_if_last_line_not_width_indicator(self):
        text_terminal = """
        +-+
        |A
        """

        with pytest.raises(ValidationError) as err_info:
            AsciiTerminal.extract_text(text_terminal)

        self.assertEqual("Last line must be a width indicator",
                         err_info.value.value)
예제 #2
0
    def test_validation_fails_if_lines_between_width_indicators_does_not_end_with_pipe(
            self):
        text_terminal = """
                +-+
                |A
                +-+
                """

        with pytest.raises(ValidationError) as err_info:
            AsciiTerminal.extract_text(text_terminal)

        self.assertEqual(
            "All lines between width indicators must end with a pipe",
            err_info.value.value)
예제 #3
0
    def test_validation_fails_if_lines_between_width_indicators_do_not_start_with_pipe(
            self):
        text_terminal = """
                +-+
                 A
                +-+
                """

        with pytest.raises(ValidationError) as err_info:
            AsciiTerminal.extract_text(text_terminal)

        self.assertEqual(
            "All lines between width indicators contain at least two pipes",
            err_info.value.value)
예제 #4
0
    def test_text_centred_in_console(self, console_size, input_image, expected_ascii_terminal):
        expected_terminal = AsciiTerminal.extract_text(expected_ascii_terminal)

        image_notification = ImageNotification()
        image_notification.set_image_path(input_image)
        cmd = create_cmd(lambda: ConsoleDisplay(console_size).draw(image_notification))
        result = CliRunner().invoke(cmd, catch_exceptions=False)

        self.assertEqual(expected_terminal, result.output)
예제 #5
0
    def test_get_text_returns_single_line_text(self):
        text_terminal = """
                +----+
                |   A|
                +----+
                """

        terminal = AsciiTerminal.extract_text(text_terminal)
        self.assertEqual("   A", terminal)
예제 #6
0
    def test_get_text_returns_multiline_text(self):
        text_terminal = """
                +----+
                |   A|
                |  B|
                +----+
                """

        terminal = AsciiTerminal.extract_text(text_terminal)
        self.assertMultiLineEqual("   A\n  B", terminal)
예제 #7
0
    def test_get_text_returns_multiline_text_without_trailing_whitespace(self):
        text_terminal = """
                +----+
                |   A|
                |  B|
                ||
                +----+
                """

        terminal = AsciiTerminal.extract_text(text_terminal)
        self.assertEqual("   A\n  B", terminal)