def test_update_player_monster_name_by_id_db(): repository_player = IRepositoryPlayer() repository_game = IRepositoryGame() repository_game.save_game('Room6') repository_player.save_player('Kraken', 'Room6') repository_player.update_player_monster_name_by_id(6, 'Cyber Bunny') assert repository_player.get_player_by_id(6).monster_name == 'Cyber Bunny'
def test_update_player_monster_name_by_username_db(): repository_player = IRepositoryPlayer() repository_game = IRepositoryGame() repository_game.save_game('Room7') repository_player.save_player('Hydra', 'Room7') repository_player.update_player_monster_name_by_username('Hydra', 'Mantis') assert repository_player.get_players_by_username_and_room('Hydra', 'Room7').monster_name == 'Mantis'
def test_update_player_username_by_id_db(): repository_player = IRepositoryPlayer() repository_game = IRepositoryGame() repository_game.save_game('Room4') repository_player.save_player('Meka Dragon', 'Room4') repository_player.update_player_username_by_id(4, 'Kong') assert repository_player.get_player_by_id(4).username == 'Kong'
def test_update_player_username_by_username_db(): repository_player = IRepositoryPlayer() repository_game = IRepositoryGame() repository_game.save_game('Room5') repository_player.save_player('Godzilla', 'Room5') repository_player.update_player_username_by_username('Godzilla', 'Mantra') assert repository_player.get_players_by_username_and_room('Mantra', 'Room5').username == 'Mantra'
def test_get_game_by_status(): repository_game = IRepositoryGame() repository_game.save_game('Room3') repository_game.save_game('Room4') result = repository_game.get_game_by_status(2) assert result[0].room_name == 'Room3' assert result[1].room_name == 'Room4'
def test_save_move_in_and_out_tokyo(): repository_play = IRepositoryPlay() repository_game = IRepositoryGame() repository_game.save_game('Room3') repository_player = IRepositoryPlayer() repository_player.save_player('Godzilla3', 'Room3') assert repository_play.save_move_in_and_out_tokyo('Godzilla3', 'Room3', '1', 10, 10, 10).id == 3
def test_save_play_card_swept_db(): repository_play = IRepositoryPlay() repository_game = IRepositoryGame() repository_game.save_game('Room1') repository_player = IRepositoryPlayer() repository_player.save_player('Godzilla1', 'Room1') assert repository_play.save_play_card_swept('Godzilla1', 'Room1', '01', '1', '02', '1', '03', '1', '1', 10, 10, 10).id == 1
def test_save_play_card_purchased_db(): repository_play = IRepositoryPlay() repository_game = IRepositoryGame() repository_game.save_game('Room2') repository_player = IRepositoryPlayer() repository_player.save_player('Godzilla2', 'Room2') assert repository_play.save_play_card_purchased('Godzilla2', 'Room2', '01', '1', '1', 10, 10, 10).id == 2
def test_get_play_by_id(): repository_play = IRepositoryPlay() repository_game = IRepositoryGame() repository_game.save_game('Room4') repository_player = IRepositoryPlayer() repository_player.save_player('Godzilla4', 'Room4') repository_play.save_play_card_swept('Godzilla4', 'Room4', '04', '1', '05', '1', '06', '1', '1', 10, 10, 10) assert repository_play.get_play_by_id(4).card1_swept == '04'
def test_delete_dice_by_id(): repository_play = IRepositoryPlay() repository_game = IRepositoryGame() repository_game.save_game('Room12') repository_player = IRepositoryPlayer() repository_player.save_player('Godzilla12', 'Room12') repository_play.save_play_card_swept('Godzilla12', 'Room12', '01', '1', '02', '1', '03', '1', '1', 10, 10, 10) assert repository_play.delete_play_by_id(12) is None
def test_get_plays_by_player_and_room(): repository_play = IRepositoryPlay() repository_game = IRepositoryGame() repository_game.save_game('Room5') repository_player = IRepositoryPlayer() repository_player.save_player('Godzilla5', 'Room5') repository_play.save_play_card_swept('Godzilla5', 'Room5', '04', '1', '05', '1', '06', '1', '1', 10, 10, 10) assert repository_play.get_plays_by_player_and_room( 'Godzilla5', 'Room5').card2_swept == '05'
def test_update_play_card_purchased(): repository_play = IRepositoryPlay() repository_game = IRepositoryGame() repository_game.save_game('Room7') repository_player = IRepositoryPlayer() repository_player.save_player('Godzilla7', 'Room7') repository_play.save_play_card_purchased('Godzilla7', 'Room7', '01', '1', '1', 10, 10, 10) repository_play.update_play_card_purchased_by_id(7, '21', '1') assert repository_play.get_play_by_id(7).card_purchased == '21'
def test_get_dice_db(): repository_dice = IRepositoryDice() repository_game = IRepositoryGame() repository_game.save_game('Room2') repository_player = IRepositoryPlayer() repository_player.save_player('Mantra', 'Room2') repository_dice.save_dice('Mantra', 'Room2', DieValue.ONE, DieValue.TWO, DieValue.THREE, DieValue.ONE, DieValue.TWO, DieValue.THREE, None, None, 1, None) assert repository_dice.get_dice_by_id(2).dice2 == 'DieValue.TWO'
def test_delete_dice_by_id(): repository_dice = IRepositoryDice() repository_game = IRepositoryGame() repository_game.save_game('Room5') repository_player = IRepositoryPlayer() repository_player.save_player('Drakonis', 'Room5') repository_dice.save_dice('Drakonis', 'Room5', DieValue.ONE, DieValue.TWO, DieValue.THREE, DieValue.ONE, DieValue.TWO, DieValue.THREE, None, None, 1, None) assert repository_dice.delete_dice_by_id(5) is None
def test_update_play_card_health_by_id(): repository_play = IRepositoryPlay() repository_game = IRepositoryGame() repository_game.save_game('Room11') repository_player = IRepositoryPlayer() repository_player.save_player('Godzilla11', 'Room11') repository_play.save_play_card_purchased('Godzilla11', 'Room11', '01', '1', '1', 10, 10, 10) repository_play.update_play_health_by_id(11, constants.DEFAULT_HEALTH) assert repository_play.get_play_by_id( 11).health_points == constants.DEFAULT_HEALTH
def test_save_dice(): repository_dice = IRepositoryDice() repository_game = IRepositoryGame() repository_game.save_game('Room1') repository_player = IRepositoryPlayer() repository_player.save_player('Godzilla1', 'Room1') assert repository_dice.save_dice('Godzilla1', 'Room1', DieValue.ONE, DieValue.TWO, DieValue.THREE, DieValue.ONE, DieValue.TWO, DieValue.THREE, None, None, 1, None).id == 1
def test_update_die_by_id(): repository_dice = IRepositoryDice() repository_game = IRepositoryGame() repository_game.save_game('Room4') repository_player = IRepositoryPlayer() repository_player.save_player('Kraken', 'Room4') repository_dice.save_dice('Kraken', 'Room4', DieValue.ONE, DieValue.TWO, DieValue.THREE, DieValue.ONE, DieValue.TWO, DieValue.THREE, None, None, 1, None) repository_dice.update_die_by_id(4, 2, DieValue.THREE, 1) assert repository_dice.get_dice_by_id(4).dice2 == 'DieValue.THREE'
def test_update_play_card_swept(): repository_play = IRepositoryPlay() repository_game = IRepositoryGame() repository_game.save_game('Room6') repository_player = IRepositoryPlayer() repository_player.save_player('Godzilla6', 'Room6') repository_play.save_play_card_swept('Godzilla6', 'Room6', '01', '1', '02', '1', '03', '1', '1', 10, 10, 10) repository_play.update_play_card_swept_by_id(6, '10', '1', '12', '1', '13', '1') assert repository_play.get_play_by_id(6).card3_swept == '13'
def test_update_play_card_location_by_id(): repository_play = IRepositoryPlay() repository_game = IRepositoryGame() repository_game.save_game('Room8') repository_player = IRepositoryPlayer() repository_player.save_player('Godzilla8', 'Room8') repository_play.save_play_card_purchased('Godzilla8', 'Room8', '01', '1', '1', 10, 10, 10) repository_play.update_play_location_by_id(8, locations.Locations.TOKYO.value) assert repository_play.get_play_by_id(8).location == '1'
def test_update_play_card_victory_point_by_id(): repository_play = IRepositoryPlay() repository_game = IRepositoryGame() repository_game.save_game('Room9') repository_player = IRepositoryPlayer() repository_player.save_player('Godzilla9', 'Room9') repository_play.save_play_card_purchased('Godzilla9', 'Room9', '01', '1', '1', 10, 10, 10) repository_play.update_play_victory_points_by_id( 9, constants.VICTORY_POINTS_TO_WIN) assert repository_play.get_play_by_id( 9).victory_points == constants.VICTORY_POINTS_TO_WIN
def test_update_play_card_energy_by_id(): repository_play = IRepositoryPlay() repository_game = IRepositoryGame() repository_game.save_game('Room10') repository_player = IRepositoryPlayer() repository_player.save_player('Godzilla10', 'Room10') repository_play.save_play_card_purchased('Godzilla10', 'Room10', '01', '1', '1', 10, 10, 10) repository_play.update_play_energy_by_id(10, constants.ENERGY_HOARDER_DIVIDER) assert repository_play.get_play_by_id( 10).energy_cube == constants.ENERGY_HOARDER_DIVIDER
def test_update_dice_db(): repository_dice = IRepositoryDice() repository_game = IRepositoryGame() repository_game.save_game('Room3') repository_player = IRepositoryPlayer() repository_player.save_player('Kong', 'Room3') repository_dice.save_dice('Kong', 'Room3', DieValue.ONE, DieValue.TWO, DieValue.THREE, DieValue.ONE, DieValue.TWO, DieValue.THREE, None, None, 1, None) repository_dice.update_dice_by_id(3, DieValue.THREE, DieValue.ONE, DieValue.TWO, DieValue.THREE, DieValue.ONE, DieValue.TWO, None, None, 1, None) assert repository_dice.get_dice_by_id(3).dice2 == 'DieValue.ONE'
def get_or_create_game(self, username, room): game, created = GameState.objects.get_or_create(room_name=room) i_repository_game = IRepositoryGame() i_repository_player = IRepositoryPlayer() if not i_repository_game.get_game_by_room(room): game_store = i_repository_game.save_game(room) else: error = 'Room already exist in analytics database, Unable to create Game with room: ' + room if not i_repository_player.get_players_by_username_and_room( username, room): player_store = i_repository_player.save_player(username, room) else: error = 'Player in this room already exist in analytics database, Unable to create Player in room: ' + room if not game: error = 'Unable to get or create Game with room: ' + room self.send_to_client(SERVER_RESPONSE, username, room, error) success = 'Chatting in with success within room: ' + room self.send_to_client(SERVER_RESPONSE, username, room, success) return game
def test_delete_game_by_room(): repository_game = IRepositoryGame() repository_game.save_game('Room14') assert repository_game.delete_game_by_room('Room14') is None
def test_get_player_by_id_db(): repository_player = IRepositoryPlayer() repository_game = IRepositoryGame() repository_game.save_game('Room2') repository_player.save_player('Giga Zaur', 'Room2') assert repository_player.get_player_by_id(2).username == 'Giga Zaur'
def test_get_players_by_username_and_room_db(): repository_player = IRepositoryPlayer() repository_game = IRepositoryGame() repository_game.save_game('Room3') repository_player.save_player('Alienoid', 'Room3') assert repository_player.get_players_by_username_and_room('Alienoid', 'Room3').username == 'Alienoid'
def test_delete_player_by_user_id_db(): repository_player = IRepositoryPlayer() repository_game = IRepositoryGame() repository_game.save_game('Room8') repository_player.save_player('Space Penguin', 'Room8') assert repository_player.delete_player_by_id(8) is None
def test_save_player_db(): repository_player = IRepositoryPlayer() repository_game = IRepositoryGame() repository_game.save_game('Room1') assert repository_player.save_player('The King', 'Room1').id == 1
def test_delete_player_by_user_id_db(): repository_player = IRepositoryPlayer() repository_game = IRepositoryGame() repository_game.save_game('Room9') repository_player.save_player('Alpha Zombie', 'Room9') assert repository_player.delete_player_by_username('Alpha Zombie') is None
def test_delete_game_by_id(): repository_game = IRepositoryGame() repository_game.save_game('Room13') assert repository_game.delete_game_by_id(13) is None