Good point, neil, KP_ENTER should count too
[naja.git] / naja / tests / test_actions.py
index d2c723a6b4082c0135da73565a44d0862afab361..fb2c370b4cf11662543479a048564c1066a5951d 100644 (file)
@@ -8,7 +8,10 @@ from naja import actions
 
 class TestActions(TestCase):
     def make_player(self, *bits):
-        return Player(sum(1 << bit for bit in bits), None)
+        player_bits = 0
+        for bit in bits:
+            player_bits |= bit
+        return Player(player_bits, None)
 
     def make_board(self, player_bits=None, locations=None):
         if locations is None:
@@ -29,6 +32,10 @@ class TestActions(TestCase):
         check_available(set([BITS.MSB]), [], False)
         check_available(set([BITS.MSB]), [BITS.MSB], True)
 
+    def test_bits_translation(self):
+        action = actions.LocationAction(set([BITS.NORTH, 'MSB']))
+        self.assertEqual(action.required_bits, set([BITS.NORTH, BITS.MSB]))
+
     def test_DoNothing(self):
         board = self.make_board()
         state_before = board.export()
@@ -39,7 +46,7 @@ class TestActions(TestCase):
     def test_LoseHealthOrMSB_MSB_clear(self):
         board = self.make_board()
         state_before = board.export()
-        actions.LoseHeathOrMSB(set()).perform_action(board, None)
+        actions.LoseHealthOrMSB(set()).perform_action(board, None)
         state_after = board.export()
         self.assertEqual(state_after['health'], state_before['health'] - 1)
 
@@ -50,7 +57,7 @@ class TestActions(TestCase):
     def test_LoseHealthOrMSB_MSB_set(self):
         board = self.make_board(player_bits=[BITS.MSB])
         state_before = board.export()
-        actions.LoseHeathOrMSB(set()).perform_action(board, None)
+        actions.LoseHealthOrMSB(set()).perform_action(board, None)
         state_after = board.export()
         self.assertEqual(board.player.bits.check_bit(BITS.MSB), False)