|
1 | 1 | import unittest |
2 | 2 |
|
3 | | -from wrw_game.enums import FightChoice, FightResult |
| 3 | +from wrw_game.enums import FightChoice, FightResult, get_fight_result |
4 | 4 |
|
5 | 5 |
|
6 | 6 | class TestFightChoice(unittest.TestCase): |
@@ -32,45 +32,46 @@ def test_draw_str(self): |
32 | 32 |
|
33 | 33 | class TestFights(unittest.TestCase): |
34 | 34 | def test_draw_warrior(self): |
35 | | - fight_result = FightChoice.WARRIOR - FightChoice.WARRIOR |
| 35 | + fight_result = get_fight_result(FightChoice.WARRIOR, |
| 36 | + FightChoice.WARRIOR) |
36 | 37 | self.assertEqual(FightResult.DRAW, fight_result) |
37 | 38 |
|
38 | 39 | def test_draw_robber(self): |
39 | | - fight_result = FightChoice.ROBBER - FightChoice.ROBBER |
| 40 | + fight_result = get_fight_result(FightChoice.ROBBER, FightChoice.ROBBER) |
40 | 41 | self.assertEqual(FightResult.DRAW, fight_result) |
41 | 42 |
|
42 | 43 | def test_draw_wizard(self): |
43 | | - fight_result = FightChoice.WIZARD - FightChoice.WIZARD |
| 44 | + fight_result = get_fight_result(FightChoice.WIZARD, FightChoice.WIZARD) |
44 | 45 | self.assertEqual(FightResult.DRAW, fight_result) |
45 | 46 |
|
46 | 47 | def test_success_warrior(self): |
47 | | - fight_result = FightChoice.WARRIOR - FightChoice.ROBBER |
| 48 | + fight_result = get_fight_result(FightChoice.WARRIOR, FightChoice.ROBBER) |
48 | 49 | self.assertEqual(FightResult.SUCCESS, fight_result) |
49 | 50 |
|
50 | 51 | def test_success_robber(self): |
51 | | - fight_result = FightChoice.ROBBER - FightChoice.WIZARD |
| 52 | + fight_result = get_fight_result(FightChoice.ROBBER, FightChoice.WIZARD) |
52 | 53 | self.assertEqual(FightResult.SUCCESS, fight_result) |
53 | 54 |
|
54 | 55 | def test_success_wizard(self): |
55 | | - fight_result = FightChoice.WIZARD - FightChoice.WARRIOR |
| 56 | + fight_result = get_fight_result(FightChoice.WIZARD, FightChoice.WARRIOR) |
56 | 57 | self.assertEqual(FightResult.SUCCESS, fight_result) |
57 | 58 |
|
58 | 59 | def test_failure_warrior(self): |
59 | | - fight_result = FightChoice.WARRIOR - FightChoice.WIZARD |
| 60 | + fight_result = get_fight_result(FightChoice.WARRIOR, FightChoice.WIZARD) |
60 | 61 | self.assertEqual(FightResult.FAILURE, fight_result) |
61 | 62 |
|
62 | 63 | def test_failure_robber(self): |
63 | | - fight_result = FightChoice.ROBBER - FightChoice.WARRIOR |
| 64 | + fight_result = get_fight_result(FightChoice.ROBBER, FightChoice.WARRIOR) |
64 | 65 | self.assertEqual(FightResult.FAILURE, fight_result) |
65 | 66 |
|
66 | 67 | def test_failure_wizard(self): |
67 | | - fight_result = FightChoice.WIZARD - FightChoice.ROBBER |
| 68 | + fight_result = get_fight_result(FightChoice.WIZARD, FightChoice.ROBBER) |
68 | 69 | self.assertEqual(FightResult.FAILURE, fight_result) |
69 | 70 |
|
70 | 71 | def test_exception(self): |
71 | | - self.assertRaises(TypeError, FightChoice.WARRIOR.__sub__, 1) |
72 | | - self.assertRaises(TypeError, FightChoice.WARRIOR.__sub__, "1") |
73 | | - self.assertRaises(TypeError, FightChoice.WARRIOR.__sub__, None) |
| 72 | + self.assertRaises(TypeError, get_fight_result, None, None) |
| 73 | + self.assertRaises(TypeError, get_fight_result, FightChoice.WARRIOR, 1) |
| 74 | + self.assertRaises(TypeError, get_fight_result, 1, FightChoice.WARRIOR) |
74 | 75 |
|
75 | 76 |
|
76 | 77 | if __name__ == "__main__": |
|
0 commit comments