Initial upload: DevDash CLI with TUI dashboard
Some checks failed
CI / test (push) Has been cancelled
Some checks failed
CI / test (push) Has been cancelled
This commit is contained in:
51
tests/test_api/test_github.py
Normal file
51
tests/test_api/test_github.py
Normal file
@@ -0,0 +1,51 @@
|
|||||||
|
import pytest
|
||||||
|
from unittest.mock import patch, AsyncMock
|
||||||
|
from src.api.github import GitHubClient
|
||||||
|
|
||||||
|
|
||||||
|
class TestGitHubClient:
|
||||||
|
@pytest.mark.asyncio
|
||||||
|
async def test_get_pull_requests(self):
|
||||||
|
client = GitHubClient(token="test_token")
|
||||||
|
mock_prs = [{"number": 1, "title": "Test PR"}]
|
||||||
|
|
||||||
|
with patch("httpx.AsyncClient.get", new_callable=AsyncMock) as mock_get:
|
||||||
|
mock_response = AsyncMock()
|
||||||
|
mock_response.json.return_value = mock_prs
|
||||||
|
mock_response.raise_for_status = AsyncMock()
|
||||||
|
mock_get.return_value = mock_response
|
||||||
|
|
||||||
|
prs = await client.get_pull_requests("owner", "repo")
|
||||||
|
|
||||||
|
assert len(prs) == 1
|
||||||
|
assert prs[0]["number"] == 1
|
||||||
|
|
||||||
|
@pytest.mark.asyncio
|
||||||
|
async def test_get_issues(self):
|
||||||
|
client = GitHubClient(token="test_token")
|
||||||
|
mock_issues = [{"number": 1, "title": "Test Issue"}]
|
||||||
|
|
||||||
|
with patch("httpx.AsyncClient.get", new_callable=AsyncMock) as mock_get:
|
||||||
|
mock_response = AsyncMock()
|
||||||
|
mock_response.json.return_value = mock_issues
|
||||||
|
mock_response.raise_for_status = AsyncMock()
|
||||||
|
mock_get.return_value = mock_response
|
||||||
|
|
||||||
|
issues = await client.get_issues("owner", "repo")
|
||||||
|
|
||||||
|
assert len(issues) == 1
|
||||||
|
|
||||||
|
@pytest.mark.asyncio
|
||||||
|
async def test_get_workflows(self):
|
||||||
|
client = GitHubClient(token="test_token")
|
||||||
|
mock_workflows = {"workflows": [{"id": 1, "name": "CI"}]}
|
||||||
|
|
||||||
|
with patch("httpx.AsyncClient.get", new_callable=AsyncMock) as mock_get:
|
||||||
|
mock_response = AsyncMock()
|
||||||
|
mock_response.json.return_value = mock_workflows
|
||||||
|
mock_response.raise_for_status = AsyncMock()
|
||||||
|
mock_get.return_value = mock_response
|
||||||
|
|
||||||
|
workflows = await client.get_workflows("owner", "repo")
|
||||||
|
|
||||||
|
assert len(workflows) == 1
|
||||||
Reference in New Issue
Block a user