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 twitch_vod_game():
	game = GlobalGame(
		game_type=BnetGameType.BGT_RANKED_STANDARD,
		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()
	return game
	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
Beispiel #4
0
def test_should_load_into_redshift_false(auth_token):
    shortid = shortuuid.uuid()
    upload_event = UploadEvent(
        descriptor_data="{}",
        file=f"uploads/2018/11/20/17/44/{shortid}.power.log",
        shortid=shortid,
        token_uuid=auth_token.key,
        user_agent="RandoTracker.com")

    upload_event.save()

    global_game = GlobalGame(game_type=BnetGameType.BGT_RANKED_STANDARD,
                             format=FormatType.FT_STANDARD,
                             match_start=timezone.now(),
                             match_end=timezone.now())

    mock_exporter = Mock()
    mock_exporter.configure_mock(is_valid_final_state=True)

    assert not should_load_into_redshift(upload_event, {"reconnecting": True},
                                         global_game, mock_exporter)

    mock_exporter.configure_mock(is_valid_final_state=False)
    assert not should_load_into_redshift(upload_event, {}, global_game,
                                         mock_exporter)
Beispiel #5
0
def test_should_load_into_redshift(auth_token):
    shortid = shortuuid.uuid()

    n = timezone.now()

    upload_event = UploadEvent(
        descriptor_data="{}",
        file=f"uploads/%04d/%02d/%02d/%02d/%02d/%s.power.log" %
        (n.year, n.month, n.day, n.hour, n.minute, shortid),
        shortid=shortid,
        token_uuid=auth_token.key,
        user_agent="RandoTracker.com")

    upload_event.save()

    global_game = GlobalGame(game_type=BnetGameType.BGT_RANKED_STANDARD,
                             format=FormatType.FT_STANDARD,
                             match_start=n,
                             match_end=n)

    mock_exporter = Mock()
    mock_exporter.configure_mock(is_valid_final_state=True)

    assert should_load_into_redshift(upload_event, {}, global_game,
                                     mock_exporter)
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
    })