def test_record_twitch_vod_ai(user, twitch_vod_game): deck = _create_deck(TEST_TWITCH_DECK_STRING_1) _create_player("Test Player 1", 1, deck, twitch_vod_game, rank=25) _create_player("Test Player 2", 2, deck, twitch_vod_game, rank=-1, is_ai=True) replay = _create_replay(user, twitch_vod_game) record_twitch_vod(replay, TEST_REPLAY_META) expected_vod = TwitchVod(hsreplaynet_user_id=user.id, rank=25, replay_shortid=replay.shortid, combined_rank="R25", **TEST_TWITCH_VOD_PARAMS) actual_vod = TwitchVod.get(TEST_REPLAY_META["twitch_vod"]["channel_name"], "R25") # Patch the TTL expected_vod.ttl = actual_vod.ttl assert expected_vod == actual_vod
def test_record_twitch_vod_arena(user): game = GlobalGame(game_type=BnetGameType.BGT_ARENA, format=FormatType.FT_STANDARD, match_start=datetime(2018, 7, 15, tzinfo=pytz.utc), match_end=datetime(2018, 7, 15, minute=5, tzinfo=pytz.utc)) game.save() deck = _create_deck(TEST_TWITCH_DECK_STRING_1) _create_player("Test Player 1", 1, deck, game, rank=0) _create_player("Test Player 2", 2, deck, game, rank=0) replay = _create_replay(user, game) record_twitch_vod(replay, TEST_REPLAY_META) expected_vod = TwitchVod(hsreplaynet_user_id=user.id, rank=0, replay_shortid=replay.shortid, combined_rank="R0", **dict(TEST_TWITCH_VOD_PARAMS, game_type="BGT_ARENA")) actual_vod = TwitchVod.get(TEST_REPLAY_META["twitch_vod"]["channel_name"], "R0") # Patch the TTL expected_vod.ttl = actual_vod.ttl assert expected_vod == actual_vod
def test_record_twitch_vod(user, twitch_vod_game): deck1 = _create_deck(TEST_TWITCH_DECK_STRING_1, archetype_id=123) deck2 = _create_deck(TEST_TWITCH_DECK_STRING_2) _create_player("Test Player 1", 1, deck1, twitch_vod_game, rank=25) _create_player("Test Player 2", 2, deck2, twitch_vod_game, rank=25) replay = _create_replay(user, twitch_vod_game) record_twitch_vod(replay, TEST_REPLAY_META) expected_vod = TwitchVod(friendly_player_archetype_id=123, hsreplaynet_user_id=user.id, rank=25, replay_shortid=replay.shortid, combined_rank="R25", **TEST_TWITCH_VOD_PARAMS) actual_vod = TwitchVod.get(TEST_REPLAY_META["twitch_vod"]["channel_name"], "R25") # Patch the TTL expected_vod.ttl = actual_vod.ttl assert expected_vod == actual_vod
def test_record_twitch_vod_missing_language(user, twitch_vod_game): deck1 = create_deck_from_deckstring(TEST_TWITCH_DECK_STRING_1, archetype_id=123) deck2 = create_deck_from_deckstring(TEST_TWITCH_DECK_STRING_2) create_player("Test Player 1", 1, deck1, twitch_vod_game, rank=25) create_player("Test Player 2", 2, deck2, twitch_vod_game, rank=25) replay = create_replay(user, twitch_vod_game) def prune_language(d: dict): return {k: v for k, v in d.items() if k != "language"} replay_meta_no_language = { "twitch_vod": prune_language(TEST_REPLAY_META["twitch_vod"]) } expected_twitch_vod_params = prune_language(TEST_TWITCH_VOD_PARAMS) record_twitch_vod(replay, replay_meta_no_language) expected_vod = TwitchVod(friendly_player_archetype_id=123, hsreplaynet_user_id=user.id, rank=25, replay_shortid=replay.shortid, combined_rank="R25", **expected_twitch_vod_params) actual_vod = TwitchVod.get(TEST_REPLAY_META["twitch_vod"]["channel_name"], "R25") # Patch the TTL expected_vod.ttl = actual_vod.ttl assert expected_vod == actual_vod
def test_record_twitch_vod_dynamodb_exception(user, twitch_vod_game): deck = create_deck_from_deckstring(TEST_TWITCH_DECK_STRING_1) create_player("Test Player 1", 1, deck, twitch_vod_game, rank=25) create_player("Test Player 2", 2, deck, twitch_vod_game, rank=25) replay = create_replay(user, twitch_vod_game) def put_item_raise(*_args, **_kwargs): raise PutError() with patch.object(TableConnection, "put_item", put_item_raise): record_twitch_vod(replay, TEST_REPLAY_META) with raises(DoesNotExist): TwitchVod.get(TEST_REPLAY_META["twitch_vod"]["channel_name"], "R25")
def test_record_twitch_vod_legend_rank(user, twitch_vod_game): deck1 = create_deck_from_deckstring(TEST_TWITCH_DECK_STRING_1, archetype_id=123) deck2 = create_deck_from_deckstring(TEST_TWITCH_DECK_STRING_2, archetype_id=456) create_player("Test Player 1", 1, deck1, twitch_vod_game, rank=0, legend_rank=50) create_player("Test Player 2", 2, deck2, twitch_vod_game, rank=0, legend_rank=49) replay = create_replay(user, twitch_vod_game) record_twitch_vod(replay, TEST_REPLAY_META) expected_vod = TwitchVod( friendly_player_archetype_id=123, hsreplaynet_user_id=user.id, legend_rank=50, opposing_player_archetype_id=456, rank=0, replay_shortid=replay.shortid, combined_rank="L50", **TEST_TWITCH_VOD_PARAMS ) actual_vod = TwitchVod.get(TEST_REPLAY_META["twitch_vod"]["channel_name"], "L50") # Patch the TTL expected_vod.ttl = actual_vod.ttl assert expected_vod == actual_vod
def test_record_twitch_vod_missing_rank(user, twitch_vod_game): deck = create_deck_from_deckstring(TEST_TWITCH_DECK_STRING_1) create_player("Test Player 1", 1, deck, twitch_vod_game, rank=None) create_player("Test Player 2", 2, deck, twitch_vod_game, rank=None) replay = create_replay(user, twitch_vod_game) record_twitch_vod(replay, TEST_REPLAY_META) expected_vod = TwitchVod(hsreplaynet_user_id=user.id, rank=0, replay_shortid=replay.shortid, combined_rank="R0", **TEST_TWITCH_VOD_PARAMS) actual_vod = TwitchVod.get(TEST_REPLAY_META["twitch_vod"]["channel_name"], "R0") # Patch the TTL expected_vod.ttl = actual_vod.ttl assert expected_vod == actual_vod