Debian Codegraph @

tests/legacy/github/test_get_org_repos.py

raw
1 # pylint: disable=missing-docstring, redefined-outer-name, unused-import
2 import json
3
4 import pytest
5
6 from aiogithubapi import GitHub
7 from aiogithubapi.common.exceptions import (
8 AIOGitHubAPINotModifiedException,
9 AIOGitHubAPIRatelimitException,
10 )
11
12 from tests.common import TOKEN
13 from tests.legacy.responses.base import base_response
14 from tests.legacy.responses.org_repositories import org_repositories_response
15
16
17 @pytest.mark.asyncio
18 async def test_get_org_repos(mock_response, org_repositories_response, client_session):
19 mock_response.mock_data = org_repositories_response
20
21 async with GitHub(TOKEN, session=client_session) as github:
22 org = await github.get_org_repos("octocat")
23 first_repo = org[0]
24 assert first_repo.description == "This your first repo!"
25 assert github.client.ratelimits.remaining == "4999"
26
27 mock_response.clear()
28 mock_response.mock_status = 304
29
30 with pytest.raises(AIOGitHubAPINotModifiedException):
31 await github.get_org_repos("octocat", etag=github.client.last_response.etag)
32
33
34 @pytest.mark.asyncio
35 async def test_get_org_repos_ratelimited(github, mock_response):
36 mock_response.mock_status = 403
37
38 with pytest.raises(AIOGitHubAPIRatelimitException):
39 await github.get_org_repos("octocat")