X-Git-Url: https://git.ctpug.org.za/?a=blobdiff_plain;f=naja%2Ftests%2Ftest_gameboard.py;h=e3aa32e03be48a27e0da319219fa880e25491c77;hb=75d1f94ef500df4bea81d8988757d37221a310dd;hp=d843c7e9fc86e2cee5e913551c08946f3f9f8d31;hpb=ee2a1f7e16272d19eb5a2dc03355ce8b851a441e;p=naja.git diff --git a/naja/tests/test_gameboard.py b/naja/tests/test_gameboard.py index d843c7e..e3aa32e 100644 --- a/naja/tests/test_gameboard.py +++ b/naja/tests/test_gameboard.py @@ -21,10 +21,15 @@ class TestGameBoard(TestCase): self.assertEqual(state1, state2) def test_export_new_board(self): - board = GameBoard.new_game([{'actions': [{ - 'action_class': 'LoseHealthOrMSB', - 'required_bits': [], - }]}]) + board = GameBoard.new_game([{'actions': [ + { + 'action_class': 'LoseHealthOrMSB', + 'required_bits': [], + }, { + 'action_class': 'GainHealth', + 'required_bits': [BITS.RED], + }, + ]}]) exported_state = board.export() board_locations = exported_state.pop('board_locations') self.assertEqual(exported_state, { @@ -32,24 +37,36 @@ class TestGameBoard(TestCase): 'health': 4, 'wins_required': 4, 'wins': 0, - 'locations': [{'actions': [{ - 'action_class': 'LoseHealthOrMSB', - 'required_bits': [], - }]}], + 'locations': [{'actions': [ + { + 'action_class': 'LoseHealthOrMSB', + 'required_bits': [], + }, { + 'action_class': 'GainHealth', + 'required_bits': [BITS.RED], + }, + ]}], 'player': board.player.export(), }) - self.assertEqual( - set(board_locations.keys()), - set((x, y) for x in range(5) for y in range(5))) - for location_state in board_locations.values(): + positions = [] + for position, location_state in board_locations: + positions.append(position) self.assertEqual( sorted(location_state.keys()), ['actions', 'bitwise_operand']) - self.assertEqual(location_state['actions'], [{ - 'action_class': 'LoseHealthOrMSB', - 'required_bits': [], - 'data': {}, - }]) + self.assertEqual(location_state['actions'], [ + { + 'action_class': 'LoseHealthOrMSB', + 'required_bits': [], + 'data': {}, + }, { + 'action_class': 'GainHealth', + 'required_bits': [BITS.RED], + 'data': {}, + }, + ]) self.assertTrue(2 <= len(location_state['bitwise_operand']) <= 3) + self.assertEqual( + positions, sorted((x, y) for x in range(5) for y in range(5))) def test_lose_health(self): board = GameBoard.new_game([{'actions': []}])