diff options
| author | 2020-06-20 01:20:35 +0200 | |
|---|---|---|
| committer | 2020-06-20 01:23:13 +0200 | |
| commit | 581573f2ece96a9ec666795431ff21068e949a63 (patch) | |
| tree | 3b60586cd0869a9519ae65b9ec1c6e40604b21e7 /tests | |
| parent | Preserve empty string when substituting clyde (diff) | |
Write unit test for `sub_clyde`
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/bot/utils/test_messages.py | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/tests/bot/utils/test_messages.py b/tests/bot/utils/test_messages.py new file mode 100644 index 000000000..9c22c9751 --- /dev/null +++ b/tests/bot/utils/test_messages.py @@ -0,0 +1,27 @@ +import unittest + +from bot.utils import messages + + +class TestMessages(unittest.TestCase): + """Tests for functions in the `bot.utils.messages` module.""" + + def test_sub_clyde(self): + """Uppercase E's and lowercase e's are substituted with their cyrillic counterparts.""" + sub_e = "\u0435" + sub_E = "\u0415" # noqa: N806: Uppercase E in variable name + + test_cases = ( + (None, None), + ("", ""), + ("clyde", f"clyd{sub_e}"), + ("CLYDE", f"CLYD{sub_E}"), + ("cLyDe", f"cLyD{sub_e}"), + ("BIGclyde", f"BIGclyd{sub_e}"), + ("small clydeus the unholy", f"small clyd{sub_e}us the unholy"), + ("BIGCLYDE, babyclyde", f"BIGCLYD{sub_E}, babyclyd{sub_e}"), + ) + + for username_in, username_out in test_cases: + with self.subTest(input=username_in, expected_output=username_out): + self.assertEqual(messages.sub_clyde(username_in), username_out) |