def test_player_add_dict_of_ships(self): player = Player('p') player.add_dict_of_ships([{"s_type":"2", "set_of_coordinates" : [{"x":"a", "y":1},{"x":"a", "y":2}]}]) expected = "a" actual = player.ships[0].set_of_coordinates[0].x self.assertEqual(expected, actual) expected = 1 actual = player.ships[0].set_of_coordinates[0].y self.assertEqual(expected, actual) expected = "a" actual = player.ships[0].set_of_coordinates[1].x self.assertEqual(expected, actual) expected = 2 actual = player.ships[0].set_of_coordinates[1].y self.assertEqual(expected, actual)
def save_setup(player_num): """ Save setup to the model Recieves setup to start with as JSON object and sends it directly to the model """ content = request.json player = Player(content['player']['name']) dict_of_ships = content['list_of_ships'] player.add_dict_of_ships(dict_of_ships) if player_num == "1": game.player1 = player if player_num == "2": game.player2 = player # return {"name": "OK"} causes bug on some computers return 'text'