|
4 | 4 | from bot.exts.info.codeblock import _instructions as instructions, _parsing as parsing |
5 | 5 |
|
6 | 6 |
|
| 7 | +class FindCodeblockWithInvalidTicksTest(unittest.TestCase): |
| 8 | + def test_should_return_codeblock_with_single_quotes(self) -> None: |
| 9 | + first_block_content = dedent(''' |
| 10 | + """A script that iterates and prints the numbers""" |
| 11 | + numbs = [1, 2, 3] |
| 12 | +
|
| 13 | + for numb in numbs: |
| 14 | + print(numb) |
| 15 | + ''').strip() |
| 16 | + first_block_language = "py" |
| 17 | + first_block_tick = parsing.BACKTICK |
| 18 | + first_block_ticks = first_block_tick * 3 |
| 19 | + |
| 20 | + second_block_content = dedent(''' |
| 21 | + """A script that iterates and prints the letters""" |
| 22 | + letters = ["a", "b", "c"] |
| 23 | +
|
| 24 | + for letter in letters: |
| 25 | + print(letter) |
| 26 | + ''').strip() |
| 27 | + second_block_language = "py" |
| 28 | + second_block_tick = "'" |
| 29 | + second_block_ticks = second_block_tick * 3 |
| 30 | + |
| 31 | + first_block = parsing.CodeBlock( |
| 32 | + first_block_content, |
| 33 | + first_block_language, |
| 34 | + first_block_ticks, |
| 35 | + first_block_tick, |
| 36 | + True, |
| 37 | + ) |
| 38 | + second_block = parsing.CodeBlock( |
| 39 | + second_block_content, |
| 40 | + second_block_language, |
| 41 | + second_block_ticks, |
| 42 | + second_block_tick, |
| 43 | + True, |
| 44 | + ) |
| 45 | + blocks = (first_block, second_block) |
| 46 | + expected_block = second_block |
| 47 | + |
| 48 | + block_with_invalid_ticks = parsing._get_block_with_invalid_ticks(blocks) |
| 49 | + |
| 50 | + self.assertEqual(block_with_invalid_ticks, expected_block) |
| 51 | + |
| 52 | + |
7 | 53 | class ProvideBadTicksInstructionsTest(unittest.TestCase): |
8 | 54 | def __assert_is_instructions_for_message_bad_ticks_one(self, message: str) -> None: |
9 | 55 | code_blocks = parsing.find_faulty_code_blocks(message) |
|
0 commit comments