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