Coverage for backend / tests / test_utils / test_github_client.py: 100%

22 statements  

« prev     ^ index     » next       coverage.py v7.13.5, created at 2026-05-02 15:51 +0000

1from pydantic import SecretStr 

2import pytest 

3 

4from app.utils.github_client import GithubClient, GithubClientError 

5 

6 

7@pytest.mark.asyncio 

8async def test_init(): 

9 async with GithubClient( 

10 SecretStr("token") 

11 ) as client: 

12 assert client._httpx_client is not None 

13 

14 

15@pytest.mark.asyncio 

16async def test_double_init(): 

17 with pytest.raises(GithubClientError, match="Client already initialized"): 

18 async with GithubClient( 

19 SecretStr("token") 

20 ) as client: 

21 async with client: 

22 pass # pragma: no cover 

23 

24 

25@pytest.mark.asyncio 

26async def test_get_latest_commits_not_initialized(): 

27 client = GithubClient(SecretStr("token")) 

28 with pytest.raises(GithubClientError, match="Client not initialized"): 

29 await client.get_latest_commits("owner", "repo") 

30 

31 

32@pytest.mark.asyncio 

33async def test_get_commit_statuses_not_initialized(): 

34 client = GithubClient(SecretStr("token")) 

35 with pytest.raises(GithubClientError, match="Client not initialized"): 

36 await client.get_commit_statuses("owner", "repo", "sha")