コード例 #1
0
ファイル: test_client.py プロジェクト: takos22/codingame
def test_client_get_challenge_leaderboard(
    client: SyncClient, challenge_id: str
):
    challenge_leaderboard = client.get_challenge_leaderboard(challenge_id)
    assert isinstance(challenge_leaderboard, ChallengeLeaderboard)
    assert isinstance(challenge_leaderboard.users[0], ChallengeRankedCodinGamer)
    if challenge_leaderboard.has_leagues:
        assert isinstance(challenge_leaderboard.leagues[0], League)
コード例 #2
0
ファイル: test_client.py プロジェクト: takos22/codingame
def test_client_get_puzzle_leaderboard_error(client: SyncClient):
    with pytest.raises(ValueError):
        client.get_puzzle_leaderboard("codingame-optim", group="nonexistent")
    with pytest.raises(exceptions.LoginRequired):
        client.get_puzzle_leaderboard("codingame-optim", group="country")
    with pytest.raises(exceptions.PuzzleNotFound):
        client.get_puzzle_leaderboard("nonexistent")
コード例 #3
0
ファイル: test_client.py プロジェクト: takos22/codingame
def test_client_get_global_leaderboard_error(client: SyncClient):
    with pytest.raises(ValueError):
        client.get_global_leaderboard(type="NONEXISTENT")
    with pytest.raises(ValueError):
        client.get_global_leaderboard(group="nonexistent")
    with pytest.raises(exceptions.LoginRequired):
        client.get_global_leaderboard(group="country")
コード例 #4
0
ファイル: test_client.py プロジェクト: takos22/codingame
def test_client_get_puzzle_leaderboard(client: SyncClient, puzzle_id: str):
    puzzle_leaderboard = client.get_puzzle_leaderboard(puzzle_id)
    assert isinstance(puzzle_leaderboard, PuzzleLeaderboard)
    assert isinstance(puzzle_leaderboard.users[0], PuzzleRankedCodinGamer)
    if puzzle_leaderboard.has_leagues:
        assert isinstance(puzzle_leaderboard.leagues[0], League)

        # test League.__eq__
        assert puzzle_leaderboard.leagues[0] == League(
            client._state,
            {
                "divisionCount": 6,
                "divisionIndex": 0,
                "divisionAgentsCount": 100,
            },
        )
コード例 #5
0
ファイル: test_client.py プロジェクト: takos22/codingame
def test_client_get_challenge_leaderboard_error(client: SyncClient):
    with pytest.raises(ValueError):
        client.get_challenge_leaderboard(
            "spring-challenge-2021", group="nonexistent"
        )
    with pytest.raises(exceptions.LoginRequired):
        client.get_challenge_leaderboard(
            "spring-challenge-2021", group="country"
        )
    with pytest.raises(exceptions.ChallengeNotFound):
        client.get_challenge_leaderboard("nonexistent")
コード例 #6
0
ファイル: test_client.py プロジェクト: takos22/codingame
def test_client_login(client: SyncClient):
    client.login(
        remember_me_cookie=os.environ.get("TEST_LOGIN_REMEMBER_ME_COOKIE"),
    )
    assert client.logged_in is True
    assert client.codingamer is not None
コード例 #7
0
ファイル: test_client.py プロジェクト: takos22/codingame
def test_client_request_error(client: SyncClient, service: str, func: str):
    with pytest.raises(ValueError):
        client.request(service, func)
コード例 #8
0
ファイル: test_client.py プロジェクト: takos22/codingame
def test_client_request(client: SyncClient):
    session = client.request("session", "findSession")
    assert isinstance(session, dict)
コード例 #9
0
ファイル: test_client.py プロジェクト: takos22/codingame
def test_client_get_clash_of_code(client: SyncClient):
    clash_of_code = client.get_clash_of_code(
        os.environ.get("TEST_CLASHOFCODE_PUBLIC_HANDLE")
    )
    assert isinstance(clash_of_code, ClashOfCode)
コード例 #10
0
ファイル: test_client.py プロジェクト: takos22/codingame
def test_client_get_global_leaderboard(client: SyncClient):
    global_leaderboard = client.get_global_leaderboard()
    assert isinstance(global_leaderboard, GlobalLeaderboard)
    assert isinstance(global_leaderboard.users[0], GlobalRankedCodinGamer)
コード例 #11
0
ファイル: test_client.py プロジェクト: takos22/codingame
def test_client_notifications_error(client: SyncClient):
    with pytest.raises(exceptions.LoginRequired):
        next(client.get_unseen_notifications())
コード例 #12
0
ファイル: test_client.py プロジェクト: takos22/codingame
def test_client_notifications(auth_client: SyncClient):
    for notification in auth_client.get_unseen_notifications():
        assert isinstance(notification, Notification)
コード例 #13
0
ファイル: test_client.py プロジェクト: takos22/codingame
def test_client_language_ids(client: SyncClient):
    language_ids = client.get_language_ids()
    assert isinstance(language_ids, list)
    assert all(isinstance(language_id, str) for language_id in language_ids)
コード例 #14
0
ファイル: test_client.py プロジェクト: takos22/codingame
def test_client_get_pending_clash_of_code(client: SyncClient):
    clash_of_code = client.get_pending_clash_of_code()
    assert isinstance(clash_of_code, ClashOfCode) or clash_of_code is None
コード例 #15
0
ファイル: test_client.py プロジェクト: takos22/codingame
def test_client_get_clash_of_code_error(client: SyncClient):
    with pytest.raises(ValueError):
        client.get_clash_of_code("0")

    with pytest.raises(exceptions.ClashOfCodeNotFound):
        client.get_clash_of_code("0" * 7 + "a" * 32)
コード例 #16
0
ファイル: test_client.py プロジェクト: takos22/codingame
def test_client_login_error(client: SyncClient, email: str, password: str):
    with pytest.raises(exceptions.LoginError):
        client.login(email, password)
コード例 #17
0
ファイル: test_client.py プロジェクト: takos22/codingame
def test_client_get_codingamer(client: SyncClient, codingamer_query):
    codingamer = client.get_codingamer(codingamer_query)
    assert isinstance(codingamer, CodinGamer)
コード例 #18
0
ファイル: test_client.py プロジェクト: takos22/codingame
def test_client_get_codingamer_error(client: SyncClient, codingamer_query):
    with pytest.raises(exceptions.CodinGamerNotFound):
        client.get_codingamer(codingamer_query)