Debian Codegraph @

tests/namespaces/test_pulls.py

raw
1 """Test contents 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, MockResponse
8
9
10 @pytest.mark.asyncio
11 async def test_list(github_api: GitHubAPI, mock_requests: MockedRequests):
12 response = await github_api.repos.pulls.list(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].title == "Awesome title"
17 assert mock_requests.called == 1
18 assert (
19 mock_requests.last_request["url"]
20 == "https://api.github.com/repos/octocat/hello-world/pulls"
21 )
22
23
24 @pytest.mark.asyncio
25 async def test_list_empty(
26 github_api: GitHubAPI,
27 mock_requests: MockedRequests,
28 mock_response: MockResponse,
29 ):
30 mock_response.mock_data = []
31 response = await github_api.repos.pulls.list(TEST_REPOSITORY_NAME)
32 assert response.status == 200
33 assert isinstance(response.data, list)
34 assert len(response.data) == 0
35 assert mock_requests.called == 1
36 assert (
37 mock_requests.last_request["url"]
38 == "https://api.github.com/repos/octocat/hello-world/pulls"
39 )