| 1 |
"""Test orgs namespace.""" |
| 2 |
# pylint: disable=missing-docstring |
| 3 |
|
| 4 |
import pytest |
| 5 |
|
| 6 |
from aiogithubapi import ( |
| 7 |
GitHubAPI, |
| 8 |
GitHubOrganizationMinimalModel, |
| 9 |
GitHubOrganizationModel, |
| 10 |
) |
| 11 |
|
| 12 |
from tests.common import TEST_ORGANIZATION, MockedRequests |
| 13 |
|
| 14 |
|
| 15 |
@pytest.mark.asyncio |
| 16 |
async def test_list_organizations(github_api: GitHubAPI, mock_requests: MockedRequests): |
| 17 |
response = await github_api.orgs.list() |
| 18 |
assert response.status == 200 |
| 19 |
assert isinstance(response.data, list) |
| 20 |
fist = response.data[0] |
| 21 |
assert isinstance(fist, GitHubOrganizationMinimalModel) |
| 22 |
assert fist.login == "github" |
| 23 |
assert mock_requests.called == 1 |
| 24 |
assert mock_requests.last_request["url"] == "https://api.github.com/organizations" |
| 25 |
|
| 26 |
|
| 27 |
@pytest.mark.asyncio |
| 28 |
async def test_get_organization(github_api: GitHubAPI, mock_requests: MockedRequests): |
| 29 |
response = await github_api.orgs.get(TEST_ORGANIZATION) |
| 30 |
assert response.status == 200 |
| 31 |
assert isinstance(response.data, GitHubOrganizationModel) |
| 32 |
assert response.data.name == "github" |
| 33 |
assert mock_requests.called == 1 |
| 34 |
assert mock_requests.last_request["url"] == "https://api.github.com/orgs/octocat" |
| 35 |
|
| 36 |
|
| 37 |
@pytest.mark.asyncio |
| 38 |
async def test_update_organization(github_api: GitHubAPI, mock_requests: MockedRequests): |
| 39 |
response = await github_api.orgs.update(TEST_ORGANIZATION, {"test": "data"}) |
| 40 |
assert response.status == 200 |
| 41 |
assert isinstance(response.data, GitHubOrganizationModel) |
| 42 |
assert response.data.name == "github" |
| 43 |
assert mock_requests.called == 1 |
| 44 |
assert mock_requests.last_request["url"] == "https://api.github.com/orgs/octocat" |