Debian Codegraph @

tests/legacy/github/test_get_repo.py

raw
1 # pylint: disable=missing-docstring, redefined-outer-name, unused-import
2 import json
3
4 import pytest
5
6 from aiogithubapi import (
7 AIOGitHubAPINotModifiedException,
8 AIOGitHubAPIRatelimitException,
9 GitHub,
10 GitHubAPI,
11 GitHubNotModifiedException,
12 )
13 from aiogithubapi.const import GitHubRequestKwarg
14
15 from tests.common import EXPECTED_ETAG, TOKEN
16 from tests.legacy.responses.base import base_response
17 from tests.legacy.responses.repository_fixture import repository_response
18
19
20 @pytest.mark.asyncio
21 async def test_get_repo(mock_response, repository_response, client_session):
22 mock_response.mock_data = repository_response
23
24 async with GitHub(TOKEN, session=client_session) as github:
25 repository = await github.get_repo("octocat/Hello-World")
26 assert repository.description == "This your first repo!"
27 assert github.client.last_response.etag == EXPECTED_ETAG
28 assert github.client.ratelimits.remaining == "4999"
29
30 mock_response.clear()
31 mock_response.mock_status = 304
32
33 with pytest.raises(AIOGitHubAPINotModifiedException):
34 await github.get_repo("octocat/Hello-World", github.client.last_response.etag)
35
36
37 @pytest.mark.asyncio
38 async def test_get_repo_ratelimited(mock_response, github):
39 mock_response.mock_status = 403
40
41 with pytest.raises(AIOGitHubAPIRatelimitException):
42 await github.get_repo("octocat/Hello-World")