| 1 |
"""Test generic api call.""" |
| 2 |
# pylint: disable=missing-docstring |
| 3 |
import pytest |
| 4 |
|
| 5 |
from aiogithubapi import GitHubAPI |
| 6 |
|
| 7 |
from tests.common import ( |
| 8 |
HEADERS_TEXT, |
| 9 |
TEST_REPOSITORY_NAME, |
| 10 |
MockedRequests, |
| 11 |
MockResponse, |
| 12 |
) |
| 13 |
|
| 14 |
|
| 15 |
@pytest.mark.asyncio |
| 16 |
async def test_markdown_base( |
| 17 |
github_api: GitHubAPI, |
| 18 |
mock_requests: MockedRequests, |
| 19 |
mock_response: MockResponse, |
| 20 |
): |
| 21 |
mock_response.mock_headers = HEADERS_TEXT |
| 22 |
response = await github_api.markdown("Lorem ipsum...") |
| 23 |
assert response.status == 200 |
| 24 |
assert response.data == "Lorem ipsum..." |
| 25 |
assert mock_requests.called == 1 |
| 26 |
assert mock_requests.last_request["method"] == "post" |
| 27 |
assert mock_requests.last_request["url"] == "https://api.github.com/markdown" |
| 28 |
assert mock_requests.last_request["json"] == { |
| 29 |
"context": None, |
| 30 |
"mode": None, |
| 31 |
"text": "Lorem ipsum...", |
| 32 |
} |
| 33 |
|
| 34 |
|
| 35 |
@pytest.mark.asyncio |
| 36 |
async def test_markdown_mode( |
| 37 |
github_api: GitHubAPI, |
| 38 |
mock_requests: MockedRequests, |
| 39 |
mock_response: MockResponse, |
| 40 |
): |
| 41 |
mock_response.mock_headers = HEADERS_TEXT |
| 42 |
response = await github_api.markdown("Lorem ipsum...", mode="gfm") |
| 43 |
assert response.status == 200 |
| 44 |
assert response.data == "Lorem ipsum..." |
| 45 |
assert mock_requests.called == 1 |
| 46 |
assert mock_requests.last_request["method"] == "post" |
| 47 |
assert mock_requests.last_request["url"] == "https://api.github.com/markdown" |
| 48 |
assert mock_requests.last_request["json"] == { |
| 49 |
"context": None, |
| 50 |
"mode": "gfm", |
| 51 |
"text": "Lorem ipsum...", |
| 52 |
} |
| 53 |
|
| 54 |
|
| 55 |
@pytest.mark.asyncio |
| 56 |
async def test_markdown_context( |
| 57 |
github_api: GitHubAPI, |
| 58 |
mock_requests: MockedRequests, |
| 59 |
mock_response: MockResponse, |
| 60 |
): |
| 61 |
mock_response.mock_headers = HEADERS_TEXT |
| 62 |
response = await github_api.markdown("Lorem ipsum...", context=TEST_REPOSITORY_NAME) |
| 63 |
assert response.status == 200 |
| 64 |
assert response.data == "Lorem ipsum..." |
| 65 |
assert mock_requests.called == 1 |
| 66 |
assert mock_requests.last_request["method"] == "post" |
| 67 |
assert mock_requests.last_request["url"] == "https://api.github.com/markdown" |
| 68 |
assert mock_requests.last_request["json"] == { |
| 69 |
"context": TEST_REPOSITORY_NAME, |
| 70 |
"mode": "gfm", |
| 71 |
"text": "Lorem ipsum...", |
| 72 |
} |