Those did nothing
[naja.git] / naja / tests / test_actions.py
index 5cf4c76011958267a324087a7a5eae9706fe6b19..891936799d4ab0827bf9aeeb5c6a781e321a3a2b 100644 (file)
@@ -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.player import Player
 from naja import actions
@@ -66,20 +66,16 @@ class TestActions(TestCase):
             TEXT = "foo %(direction)s %(rowcol)s"
 
         action_north = DirectionAction([], direction='NORTH')
-        self.assertEqual(action_north.get_text(), "foo NORTH column")
+        self.assertEqual(action_north.get_text(), "foo {NORTH} column")
 
         action_south = DirectionAction([], direction='SOUTH')
-        self.assertEqual(action_south.get_text(), "foo SOUTH column")
+        self.assertEqual(action_south.get_text(), "foo {SOUTH} column")
 
         action_east = DirectionAction([], direction='EAST')
-        self.assertEqual(action_east.get_text(), "foo EAST row")
+        self.assertEqual(action_east.get_text(), "foo {EAST} row")
 
         action_west = DirectionAction([], direction='WEST')
-        self.assertEqual(action_west.get_text(), "foo WEST row")
-
-    def test_bits_translation(self):
-        action = actions.LocationAction(set([BITS.NORTH, 'MSB']))
-        self.assertEqual(action.required_bits, set([BITS.NORTH, BITS.MSB]))
+        self.assertEqual(action_west.get_text(), "foo {WEST} row")
 
     def test_DoNothing(self):
         board = self.make_board()
@@ -191,3 +187,24 @@ class TestActions(TestCase):
         self.assert_state(
             state_before, state_after, exclude=['health'],
             player_exclude=['bits'])
+
+    def test_AllowKnightMove(self):
+        board = self.make_board(player_bits=[BITS.RED, BITS.BLUE])
+        actions.AllowChessMove(
+            set([BITS.RED, BITS.BLUE]), chesspiece="KNIGHT"
+        ).perform_action(board, None)
+        self.assertEqual(board.player.movement_mode, MOVES.KNIGHT)
+
+    def test_AllowBishopMove(self):
+        board = self.make_board(player_bits=[BITS.RED, BITS.BLUE])
+        actions.AllowChessMove(
+            set([BITS.RED, BITS.BLUE]), chesspiece="BISHOP"
+        ).perform_action(board, None)
+        self.assertEqual(board.player.movement_mode, MOVES.BISHOP)
+
+    def test_AllowCastleMove(self):
+        board = self.make_board(player_bits=[BITS.RED, BITS.BLUE])
+        actions.AllowChessMove(
+            set([BITS.RED, BITS.BLUE]), chesspiece="CASTLE"
+        ).perform_action(board, None)
+        self.assertEqual(board.player.movement_mode, MOVES.CASTLE)