X-Git-Url: https://git.ctpug.org.za/?a=blobdiff_plain;f=naja%2Ftests%2Ftest_actions.py;h=fb2c370b4cf11662543479a048564c1066a5951d;hb=2db0ff32db75f5e1c2735b793410d0ebd3b7e2a3;hp=d2c723a6b4082c0135da73565a44d0862afab361;hpb=5ef59d0391e208e0ef9d4fa998b3a8e653cc57bf;p=naja.git diff --git a/naja/tests/test_actions.py b/naja/tests/test_actions.py index d2c723a..fb2c370 100644 --- a/naja/tests/test_actions.py +++ b/naja/tests/test_actions.py @@ -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)