| 1 |
"""Test contents namespace.""" |
| 2 |
# pylint: disable=missing-docstring |
| 3 |
import pytest |
| 4 |
|
| 5 |
from aiogithubapi import GitHubAPI, GitHubContentsModel |
| 6 |
|
| 7 |
from tests.common import TEST_REPOSITORY_NAME, MockedRequests |
| 8 |
|
| 9 |
|
| 10 |
@pytest.mark.asyncio |
| 11 |
async def test_get_root(github_api: GitHubAPI, mock_requests: MockedRequests): |
| 12 |
response = await github_api.repos.contents.get(TEST_REPOSITORY_NAME) |
| 13 |
assert response.status == 200 |
| 14 |
assert isinstance(response.data, list) |
| 15 |
assert len(response.data) == 1 |
| 16 |
assert response.data[0].name == "README" |
| 17 |
assert mock_requests.called == 1 |
| 18 |
assert ( |
| 19 |
mock_requests.last_request["url"] |
| 20 |
== "https://api.github.com/repos/octocat/hello-world/contents" |
| 21 |
) |
| 22 |
|
| 23 |
|
| 24 |
@pytest.mark.asyncio |
| 25 |
async def test_get_readme(github_api: GitHubAPI, mock_requests: MockedRequests): |
| 26 |
response = await github_api.repos.contents.get(TEST_REPOSITORY_NAME, "README") |
| 27 |
assert response.status == 200 |
| 28 |
assert isinstance(response.data, GitHubContentsModel) |
| 29 |
assert response.data.name == "README" |
| 30 |
assert mock_requests.called == 1 |
| 31 |
assert ( |
| 32 |
mock_requests.last_request["url"] |
| 33 |
== "https://api.github.com/repos/octocat/hello-world/contents/README" |
| 34 |
) |