def _create_replay(user, game, friendly_player_id=1): replay = GameReplay(user=user, global_game=game, friendly_player_id=friendly_player_id, shortid=ShortUUID().random()) replay.save() return replay
def test_post(self, client, settings, user): game = GlobalGame() game.save() replay = GameReplay(global_game=game, user=user) replay.save() client.force_login(user, backend=settings.AUTHENTICATION_BACKENDS[0]) response = client.post("/account/delete/replays/") assert response.status_code == 302 assert response["Location"] == DeleteReplaysView.success_url assert User.objects.filter(username="******").count() == 1 assert GameReplay.objects.filter(user=user, is_deleted=False).count() == 0
def test_update_replay_feed_deleted_user(mocker, user): game = GlobalGame(format=FormatType.FT_STANDARD, game_type=BnetGameType.BGT_RANKED_STANDARD, match_end=timezone.now()) game.save() archetype = Archetype(name="Test Archetype", player_class=CardClass.WARRIOR) archetype.save() deck = Deck(archetype=archetype) deck.save() _create_player("Test 1", 1, deck, game) _create_player("Test 2", 2, deck, game) replay = GameReplay(global_game=game, user=user) replay.save() user.delete() mock_replay_feed = Mock() mocker.patch("hsreplaynet.games.processing.get_replay_feed", new=lambda comparator: mock_replay_feed) update_replay_feed(replay) mock_replay_feed.push.assert_called_once_with({ "id": ANY, "player1_archetype": archetype.id, "player1_legend_rank": None, "player1_rank": 25, "player1_won": False, "player2_archetype": archetype.id, "player2_legend_rank": None, "player2_rank": 25, "player2_won": False })