Fix tests.
[naja.git] / naja / tests / test_actions.py
index 0717f0cfd6899cf3b15eaba3dab3a28bf47e6bcf..b233df76adc709c73ac0ea31570f9b20cc40cc84 100644 (file)
@@ -26,6 +26,9 @@ class TestActions(TestCase):
             board.player.bits.set_bits(player_bits)
         return board
 
+    def make_location_card(self, bits=(), name='card', actions=()):
+        return LocationCard(name, set(bits), list(actions), None)
+
     def assert_player_bits(self, board, *bits):
         self.assertEqual(sum(1 << bit for bit in bits), board.player.bits.bits)
 
@@ -107,7 +110,7 @@ class TestActions(TestCase):
     def test_SetBits(self):
         board = self.make_board()
         state_before = board.export()
-        card = LocationCard('card', set([BITS.MSB, BITS.NORTH]), [])
+        card = self.make_location_card([BITS.MSB, BITS.NORTH])
         actions.SetBits(set()).perform_action(board, card)
         state_after = board.export()
         self.assertEqual(
@@ -117,7 +120,7 @@ class TestActions(TestCase):
     def test_ToggleBits(self):
         board = self.make_board(player_bits=[BITS.NORTH])
         state_before = board.export()
-        card = LocationCard('card', set([BITS.MSB, BITS.NORTH]), [])
+        card = self.make_location_card([BITS.MSB, BITS.NORTH])
         actions.ToggleBits(set()).perform_action(board, card)
         state_after = board.export()
         self.assertEqual(board.player.bits.check_bit(BITS.MSB), True)
@@ -127,7 +130,7 @@ class TestActions(TestCase):
     def test_LoseHealthOrMSBAndSetBits_MSB_clear(self):
         board = self.make_board(player_bits=[])
         state_before = board.export()
-        card = LocationCard('card', set([BITS.BLUE, BITS.NORTH]), [])
+        card = self.make_location_card([BITS.BLUE, BITS.NORTH])
         actions.LoseHealthOrMSBAndSetBits(set()).perform_action(board, card)
         state_after = board.export()
         self.assertEqual(state_after['health'], state_before['health'] - 1)
@@ -139,7 +142,7 @@ class TestActions(TestCase):
     def test_LoseHealthOrMSBAndSetBits_MSB_set(self):
         board = self.make_board(player_bits=[BITS.MSB])
         state_before = board.export()
-        card = LocationCard('card', set([BITS.BLUE, BITS.NORTH]), [])
+        card = self.make_location_card([BITS.BLUE, BITS.NORTH])
         actions.LoseHealthOrMSBAndSetBits(set()).perform_action(board, card)
         state_after = board.export()
         self.assert_player_bits(board, BITS.BLUE, BITS.NORTH)
@@ -148,7 +151,7 @@ class TestActions(TestCase):
     def test_LoseHealthOrMSBAndSetBits_MSB_set_and_on_card(self):
         board = self.make_board(player_bits=[BITS.MSB])
         state_before = board.export()
-        card = LocationCard('card', set([BITS.MSB, BITS.NORTH]), [])
+        card = self.make_location_card([BITS.MSB, BITS.NORTH])
         actions.LoseHealthOrMSBAndSetBits(set()).perform_action(board, card)
         state_after = board.export()
         self.assert_player_bits(board, BITS.MSB, BITS.NORTH)
@@ -170,7 +173,7 @@ class TestActions(TestCase):
         board = self.make_board(player_bits=[BITS.NORTH])
         board.lose_health()
         state_before = board.export()
-        card = LocationCard('card', set([BITS.BLUE, BITS.NORTH]), [])
+        card = self.make_location_card([BITS.BLUE, BITS.NORTH])
         actions.GainHealthAndClearBitsOrMSB(set()).perform_action(board, card)
         state_after = board.export()
         self.assertEqual(state_after['health'], state_before['health'] + 1)
@@ -183,7 +186,7 @@ class TestActions(TestCase):
         board = self.make_board(player_bits=[BITS.MSB, BITS.NORTH])
         board.lose_health()
         state_before = board.export()
-        card = LocationCard('card', set([BITS.BLUE, BITS.NORTH]), [])
+        card = self.make_location_card([BITS.BLUE, BITS.NORTH])
         actions.GainHealthAndClearBitsOrMSB(set()).perform_action(board, card)
         state_after = board.export()
         self.assertEqual(state_after['health'], state_before['health'] + 1)