X-Git-Url: https://git.ctpug.org.za/?a=blobdiff_plain;f=naja%2Ftests%2Ftest_gameboard.py;h=3bbf59bcf6e21d8cc916e37079c5a19eb04ebdbe;hb=5fe12b55d1908f850145eec16a1ee2c8e61ba6ef;hp=5dae954fafaae21a532b7a7d842b408f6d210101;hpb=02ac35df9206ceaf9469ce5e77555b4809c1abcf;p=naja.git diff --git a/naja/tests/test_gameboard.py b/naja/tests/test_gameboard.py index 5dae954..3bbf59b 100644 --- a/naja/tests/test_gameboard.py +++ b/naja/tests/test_gameboard.py @@ -1,6 +1,6 @@ from unittest import TestCase -from naja.constants import BITS +from naja.constants import BITS, MOVES from naja.gameboard import GameBoard, LocationCard from naja import actions @@ -124,6 +124,25 @@ class TestGameBoard(TestCase): (0, 2): '12', (1, 2): '32', (3, 2): '42', (4, 2): '02', })) + def test_allow_chess_move_knight(self): + board = GameBoard.new_game([{'actions': []}]) + board.board_locations = self.generate_locations() + board.allow_chess_move(MOVES.KNIGHT) + self.assertEqual(board.player.movement_mode, MOVES.KNIGHT) + + def test_allow_chess_move_bishop(self): + board = GameBoard.new_game([{'actions': []}]) + board.board_locations = self.generate_locations() + board.allow_chess_move(MOVES.BISHOP) + self.assertEqual(board.player.movement_mode, MOVES.BISHOP) + + def test_allow_chess_move_castle(self): + board = GameBoard.new_game([{'actions': []}]) + board.board_locations = self.generate_locations() + board.allow_chess_move(MOVES.CASTLE) + self.assertEqual(board.player.movement_mode, MOVES.CASTLE) + + class TestLocationCard(TestCase): def test_generate_bitwise_operand(self): @@ -155,3 +174,14 @@ class TestLocationCard(TestCase): [action] = location.actions self.assertEqual(type(action), actions.DoNothing) self.assertEqual(action.required_bits, set()) + + def test_parse_bits(self): + self.assertEqual( + LocationCard.parse_bits([]), frozenset([])) + self.assertEqual( + LocationCard.parse_bits(['RED']), frozenset([BITS.RED])) + self.assertEqual( + LocationCard.parse_bits([BITS.BLUE]), frozenset([BITS.BLUE])) + self.assertEqual( + LocationCard.parse_bits([BITS.NORTH, 'MSB']), + frozenset([BITS.NORTH, BITS.MSB]))