Files
devdash-cli/tests/test_api/test_gitlab.py
7000pctAUTO 2458ab7482
Some checks failed
CI / test (push) Has been cancelled
Initial upload: DevDash CLI with TUI dashboard
2026-02-01 06:53:08 +00:00

51 lines
1.8 KiB
Python

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