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:
50
tests/test_api/test_gitlab.py
Normal file
50
tests/test_api/test_gitlab.py
Normal file
@@ -0,0 +1,50 @@
|
|||||||
|
import pytest
|
||||||
|
from unittest.mock import patch, AsyncMock
|
||||||
|
from src.api.gitlab import GitLabClient
|
||||||
|
|
||||||
|
|
||||||
|
class TestGitLabClient:
|
||||||
|
@pytest.mark.asyncio
|
||||||
|
async def test_get_pull_requests(self):
|
||||||
|
client = GitLabClient(token="test_token")
|
||||||
|
mock_mrs = [{"iid": 1, "title": "Test MR"}]
|
||||||
|
|
||||||
|
with patch("httpx.AsyncClient.get", new_callable=AsyncMock) as mock_get:
|
||||||
|
mock_response = AsyncMock()
|
||||||
|
mock_response.json.return_value = mock_mrs
|
||||||
|
mock_response.raise_for_status = AsyncMock()
|
||||||
|
mock_get.return_value = mock_response
|
||||||
|
|
||||||
|
mrs = await client.get_pull_requests("owner", "repo")
|
||||||
|
|
||||||
|
assert len(mrs) == 1
|
||||||
|
|
||||||
|
@pytest.mark.asyncio
|
||||||
|
async def test_get_issues(self):
|
||||||
|
client = GitLabClient(token="test_token")
|
||||||
|
mock_issues = [{"iid": 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 = GitLabClient(token="test_token")
|
||||||
|
mock_pipelines = [{"id": 1, "status": "success"}]
|
||||||
|
|
||||||
|
with patch("httpx.AsyncClient.get", new_callable=AsyncMock) as mock_get:
|
||||||
|
mock_response = AsyncMock()
|
||||||
|
mock_response.json.return_value = mock_pipelines
|
||||||
|
mock_response.raise_for_status = AsyncMock()
|
||||||
|
mock_get.return_value = mock_response
|
||||||
|
|
||||||
|
pipelines = await client.get_workflows("owner", "repo")
|
||||||
|
|
||||||
|
assert len(pipelines) == 1
|
||||||
Reference in New Issue
Block a user