Outline: 7 definitions
| 1 | import unittest |
| 2 | |
| 3 | import chess |
| 4 | |
| 5 | from schach.duo import badge_ply |
| 6 | |
| 7 | W, B = chess.WHITE, chess.BLACK |
| 8 | |
| 9 | |
| 10 | class BadgeTest(unittest.TestCase): |
| 11 | # Halbzüge 0 (Weiß), 1 (Schwarz), 2 (Weiß), 3 (Schwarz); Weiß ist am Zug (4 Halbzüge gespielt) |
| 12 | symbols = {2: "?!", 3: "??"} |
| 13 | |
| 14 | def test_none_sees_nothing(self): |
| 15 | self.assertIsNone(badge_ply(4, W, W, "none", self.symbols)) |
| 16 | |
| 17 | def test_all_prefers_opponents_last_move(self): |
| 18 | self.assertEqual(badge_ply(4, W, W, "all", self.symbols), 3) |
| 19 | |
| 20 | def test_own_shows_own_last_move_only(self): |
| 21 | self.assertEqual(badge_ply(4, W, W, "own", self.symbols), 2) |
| 22 | self.assertIsNone(badge_ply(4, W, W, "own", {3: "??"})) |
| 23 | |
| 24 | def test_all_falls_back_to_own(self): |
| 25 | self.assertEqual(badge_ply(4, W, W, "all", {2: "?"}), 2) |
| 26 | |
| 27 | def test_black_starts_from_fen(self): |
| 28 | # erster Halbzug von Schwarz: Halbzug 0 = Schwarz, 1 = Weiß; Schwarz ist am Zug |
| 29 | self.assertEqual(badge_ply(2, B, B, "all", {1: "??"}), 1) |
| 30 | self.assertEqual(badge_ply(2, B, B, "own", {0: "!"}), 0) |
| 31 | |
| 32 | def test_empty_game(self): |
| 33 | self.assertIsNone(badge_ply(0, W, W, "all", {})) |
| 34 | |
| 35 | |
| 36 | if __name__ == "__main__": |
| 37 | unittest.main() |