From 2458ab748291746b0fdd2d23d21d4f0126449e6a Mon Sep 17 00:00:00 2001 From: 7000pctAUTO Date: Sun, 1 Feb 2026 06:53:08 +0000 Subject: [PATCH] Initial upload: DevDash CLI with TUI dashboard --- tests/test_api/test_gitlab.py | 50 +++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 tests/test_api/test_gitlab.py diff --git a/tests/test_api/test_gitlab.py b/tests/test_api/test_gitlab.py new file mode 100644 index 0000000..454eac2 --- /dev/null +++ b/tests/test_api/test_gitlab.py @@ -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