|
6 | 6 |
|
7 | 7 |
|
8 | 8 | class AppTestCase(unittest.TestCase): |
| 9 | + def test_handle_error(self) -> None: |
| 10 | + self.assertEqual(app.handle_error("message"), "Unknown command: message") |
| 11 | + |
9 | 12 | def test_base_case_thumbsup(self) -> None: |
10 | | - app.multiplier = 1 |
11 | | - app.separator = "" |
12 | | - app.translation_toggle = False |
13 | | - self.assertEqual(app.generate_response("1 :thumbsup:"), "👍") |
| 13 | + self.assertEqual(app.format_message("1 :thumbsup:", 1, "", False), "👍") |
14 | 14 |
|
15 | 15 | def test_base_case_thumbsdown(self) -> None: |
16 | | - app.multiplier = 1 |
17 | | - app.separator = "" |
18 | | - app.translation_toggle = False |
19 | | - self.assertEqual(app.generate_response("2 :thumbsdown:"), "👎👎") |
| 16 | + self.assertEqual(app.format_message("2 :thumbsdown:", 1, "", False), "👎👎") |
20 | 17 |
|
21 | 18 | def test_base_case_ok(self) -> None: |
22 | | - app.multiplier = 1 |
23 | | - app.separator = "" |
24 | | - app.translation_toggle = False |
25 | | - self.assertEqual(app.generate_response("5 :ok:"), "👌👌👌👌👌") |
| 19 | + self.assertEqual(app.format_message("5 :ok:", 1, "", False), "👌👌👌👌👌") |
26 | 20 |
|
27 | 21 | def test_base_case_crossed(self) -> None: |
28 | | - app.multiplier = 1 |
29 | | - app.separator = "" |
30 | | - app.translation_toggle = False |
31 | | - self.assertEqual(app.generate_response("10 :crossed:"), "🤞🤞🤞🤞🤞🤞🤞🤞🤞🤞") |
| 22 | + self.assertEqual(app.format_message("10 :crossed:", 1, "", False), "🤞🤞🤞🤞🤞🤞🤞🤞🤞🤞") |
32 | 23 |
|
33 | 24 | def test_separator_1_thumbsup(self) -> None: |
34 | | - app.multiplier = 1 |
35 | | - app.separator = "," |
36 | | - app.translation_toggle = False |
37 | | - self.assertEqual(app.generate_response("1 :thumbsup:"), "👍") |
| 25 | + self.assertEqual(app.format_message("1 :thumbsup:", 1, ",", False), "👍") |
38 | 26 |
|
39 | 27 | def test_separator_2_thumbsup(self) -> None: |
40 | | - app.multiplier = 1 |
41 | | - app.separator = "," |
42 | | - app.translation_toggle = False |
43 | | - self.assertEqual(app.generate_response("2 :thumbsup:"), "👍,👍") |
| 28 | + self.assertEqual(app.format_message("2 :thumbsup:", 1, ",", False), "👍,👍") |
44 | 29 |
|
45 | 30 | def test_separator_3_thumbsup(self) -> None: |
46 | | - app.multiplier = 1 |
47 | | - app.separator = "," |
48 | | - app.translation_toggle = False |
49 | | - self.assertEqual(app.generate_response("3 :thumbsup:"), "👍,👍,👍") |
| 31 | + self.assertEqual(app.format_message("3 :thumbsup:", 1, ",", False), "👍,👍,👍") |
50 | 32 |
|
51 | 33 | def test_no_translation_1_thumbsup(self) -> None: |
52 | | - app.multiplier = 1 |
53 | | - app.separator = "" |
54 | | - app.translation_toggle = True |
55 | | - self.assertEqual(app.generate_response("1 :thumbsup:"), ":thumbsup:") |
| 34 | + self.assertEqual(app.format_message("1 :thumbsup:", 1, "", True), ":thumbsup:") |
56 | 35 |
|
57 | 36 | def test_no_translation_2_thumbsup(self) -> None: |
58 | | - app.multiplier = 1 |
59 | | - app.separator = "" |
60 | | - app.translation_toggle = True |
61 | | - self.assertEqual(app.generate_response("2 :thumbsup:"), ":thumbsup::thumbsup:") |
| 37 | + self.assertEqual( |
| 38 | + app.format_message("2 :thumbsup:", 1, "", True), ":thumbsup::thumbsup:" |
| 39 | + ) |
62 | 40 |
|
63 | 41 | def test_no_translation_3_thumbsup(self) -> None: |
64 | | - app.multiplier = 1 |
65 | | - app.separator = "" |
66 | | - app.translation_toggle = True |
67 | 42 | self.assertEqual( |
68 | | - app.generate_response("3 :thumbsup:"), ":thumbsup::thumbsup::thumbsup:" |
| 43 | + app.format_message("3 :thumbsup:", 1, "", True), |
| 44 | + ":thumbsup::thumbsup::thumbsup:", |
69 | 45 | ) |
70 | 46 |
|
71 | 47 | def test_multiplier_2_thumbsup(self) -> None: |
72 | | - app.multiplier = 2 |
73 | | - app.separator = "" |
74 | | - app.translation_toggle = False |
75 | | - self.assertEqual(app.generate_response("1 :thumbsup:"), "👍👍") |
| 48 | + self.assertEqual(app.format_message("1 :thumbsup:", 2, "", False), "👍👍") |
76 | 49 |
|
77 | 50 | def test_multiplier_3_thumbsup(self) -> None: |
78 | | - app.multiplier = 3 |
79 | | - app.separator = "" |
80 | | - app.translation_toggle = False |
81 | | - self.assertEqual(app.generate_response("1 :thumbsup:"), "👍👍👍") |
| 51 | + self.assertEqual(app.format_message("1 :thumbsup:", 3, "", False), "👍👍👍") |
82 | 52 |
|
83 | 53 | def test_multiplier_5_thumbsup(self) -> None: |
84 | | - app.multiplier = 5 |
85 | | - app.separator = "" |
86 | | - app.translation_toggle = False |
87 | | - self.assertEqual(app.generate_response("1 :thumbsup:"), "👍👍👍👍👍") |
| 54 | + self.assertEqual(app.format_message("1 :thumbsup:", 5, "", False), "👍👍👍👍👍") |
88 | 55 |
|
89 | 56 | def test_complex_ok_1(self) -> None: |
90 | | - app.multiplier = 2 |
91 | | - app.separator = "++" |
92 | | - app.translation_toggle = False |
93 | | - self.assertEqual(app.generate_response("2 :ok:"), "👌++👌++👌++👌") |
| 57 | + self.assertEqual(app.format_message("2 :ok:", 2, "++", False), "👌++👌++👌++👌") |
94 | 58 |
|
95 | 59 | def test_complex_ok_2(self) -> None: |
96 | | - app.multiplier = 3 |
97 | | - app.separator = " " |
98 | | - app.translation_toggle = True |
99 | 60 | self.assertEqual( |
100 | | - app.generate_response("2 :ok:"), ":ok: :ok: :ok: :ok: :ok: :ok:" |
| 61 | + app.format_message("2 :ok:", 3, " ", True), ":ok: :ok: :ok: :ok: :ok: :ok:" |
101 | 62 | ) |
102 | 63 |
|
103 | 64 | def test_complex_ok_2(self) -> None: |
104 | | - app.multiplier = 3 |
105 | | - app.separator = " " |
106 | | - app.translation_toggle = True |
107 | 65 | self.assertEqual( |
108 | | - app.generate_response("2 :ok:"), ":ok: :ok: :ok: :ok: :ok: :ok:" |
| 66 | + app.format_message("2 :ok:", 3, " ", True), ":ok: :ok: :ok: :ok: :ok: :ok:" |
109 | 67 | ) |
110 | 68 |
|
111 | 69 | def test_failure(self) -> None: |
| 70 | + val = "" |
| 71 | + self.assertEqual( |
| 72 | + app.format_message(val, 1, "", False), f"Unknown command: {val}" |
| 73 | + ) |
| 74 | + |
| 75 | + def test_failure_1(self) -> None: |
112 | 76 | val = "x" |
113 | | - self.assertEqual(app.generate_response(val), f"Unknown command: {val}") |
| 77 | + self.assertEqual( |
| 78 | + app.format_message(val, 1, "", False), f"Unknown command: {val}" |
| 79 | + ) |
114 | 80 |
|
115 | | - def test_failure(self) -> None: |
| 81 | + def test_failure_2(self) -> None: |
116 | 82 | val = "x :ok:" |
117 | | - self.assertEqual(app.generate_response(val), f"Unknown command: {val}") |
| 83 | + self.assertEqual( |
| 84 | + app.format_message(val, 1, "", False), f"Unknown command: {val}" |
| 85 | + ) |
118 | 86 |
|
119 | | - def test_failure(self) -> None: |
| 87 | + def test_failure_3(self) -> None: |
120 | 88 | val = "1 :okokokokok:" |
121 | | - self.assertEqual(app.generate_response(val), f"Unknown command: {val}") |
| 89 | + self.assertEqual( |
| 90 | + app.format_message(val, 1, "", False), f"Unknown command: {val}" |
| 91 | + ) |
| 92 | + |
| 93 | + def test_failure_4(self) -> None: |
| 94 | + val = "1 :ok: :ok:" |
| 95 | + self.assertEqual( |
| 96 | + app.format_message(val, 1, "", False), f"Unknown command: {val}" |
| 97 | + ) |
122 | 98 |
|
123 | 99 |
|
124 | 100 | if __name__ == "__main__": |
|
0 commit comments