|
| 1 | +from tests.unit.no_cheat import no_cheat |
| 2 | + |
| 3 | + |
| 4 | +def test_no_cheat_returns_empty_string_for_empty_diff(): |
| 5 | + diff_data = "" |
| 6 | + result = no_cheat(diff_data) |
| 7 | + assert not result |
| 8 | + |
| 9 | + |
| 10 | +def test_no_cheat_returns_empty_string_for_no_cheat_diff(): |
| 11 | + diff_data = """ |
| 12 | ++some code |
| 13 | +-some other code |
| 14 | +""" |
| 15 | + result = no_cheat(diff_data) |
| 16 | + assert not result |
| 17 | + |
| 18 | + |
| 19 | +def test_no_cheat_returns_empty_string_for_removed_cheat(): |
| 20 | + diff_data = """ |
| 21 | ++some code |
| 22 | +-some other code # pylint: disable=some-rule |
| 23 | +""" |
| 24 | + result = no_cheat(diff_data) |
| 25 | + assert not result |
| 26 | + |
| 27 | + |
| 28 | +def test_no_cheat_returns_empty_string_for_replaced_cheat(): |
| 29 | + diff_data = """ |
| 30 | ++some code # pylint: disable=some-rule |
| 31 | +-some other code # pylint: disable=some-rule |
| 32 | +""" |
| 33 | + result = no_cheat(diff_data) |
| 34 | + assert not result |
| 35 | + |
| 36 | + |
| 37 | +def test_no_cheat_returns_message_for_single_cheat(): |
| 38 | + diff_data = """ |
| 39 | ++some code # pylint: disable=some-rule |
| 40 | +-some other code |
| 41 | +""" |
| 42 | + result = no_cheat(diff_data) |
| 43 | + assert result == "Do not cheat the linter: found 1 additional # pylint: disable=some-rule" |
| 44 | + |
| 45 | + |
| 46 | +def test_no_cheat_returns_message_for_multiple_same_cheat(): |
| 47 | + diff_data = """ |
| 48 | ++some code # pylint: disable=some-rule |
| 49 | +-some other code |
| 50 | ++some code # pylint: disable=some-rule |
| 51 | +""" |
| 52 | + result = no_cheat(diff_data) |
| 53 | + assert result == "Do not cheat the linter: found 2 additional # pylint: disable=some-rule" |
| 54 | + |
| 55 | + |
| 56 | +def test_no_cheat_returns_message_for_multiple_cheats_in_different_lines(): |
| 57 | + diff_data = """ |
| 58 | ++some code # pylint: disable=some-rule |
| 59 | +-some other code |
| 60 | ++some code # pylint: disable=some-other-rule |
| 61 | +""" |
| 62 | + result = no_cheat(diff_data) |
| 63 | + assert result == ( |
| 64 | + "Do not cheat the linter: found 1 additional # pylint: disable=some-rule\n" |
| 65 | + "Do not cheat the linter: found 1 additional # pylint: disable=some-other-rule" |
| 66 | + ) |
| 67 | + |
| 68 | + |
| 69 | +def test_no_cheat_returns_message_for_multiple_cheats_in_same_lines(): |
| 70 | + diff_data = """ |
| 71 | ++some code # pylint: disable=some-rule, some-other-rule |
| 72 | +-some other code |
| 73 | +""" |
| 74 | + result = no_cheat(diff_data) |
| 75 | + assert result == ( |
| 76 | + "Do not cheat the linter: found 1 additional # pylint: disable=some-rule\n" |
| 77 | + "Do not cheat the linter: found 1 additional # pylint: disable=some-other-rule" |
| 78 | + ) |
0 commit comments