Skip to content

Commit

Permalink
👷 Chore: run unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
guptadev21 committed Dec 2, 2024
1 parent 3e84554 commit ca0d358
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 21 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/quality-checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,5 @@ jobs:
run: |
uv sync --all-extras --dev
source .venv/bin/activate
uv run pytest tests/
uv run pytest tests/sync_tests --cov
uv run pytest tests/async_tests --cov
40 changes: 20 additions & 20 deletions tests/async_tests/test_project.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import pytest
import pytest_asyncio
import pytest_asyncio # noqa: F401
import httpx
from munch import Munch
from asyncmock import AsyncMock
Expand Down Expand Up @@ -29,7 +29,7 @@ async def test_list_projects_success(client, mocker: AsyncMock): # noqa: F811


@pytest.mark.asyncio
async def test_create_project_success(client, mocker: AsyncMock):
async def test_create_project_success(client, mocker: AsyncMock): # noqa: F811
mock_post = mocker.patch("httpx.AsyncClient.post")

mock_post.return_value = httpx.Response(
Expand All @@ -49,51 +49,51 @@ async def test_create_project_success(client, mocker: AsyncMock):

assert isinstance(response, Munch)
assert response["metadata"]["guid"] == "mock_project_guid"



@pytest.mark.asyncio
async def test_get_project_success(client, mocker: AsyncMock):
async def test_get_project_success(client, mocker: AsyncMock): # noqa: F811
mock_get = mocker.patch("httpx.AsyncClient.get")

mock_get.return_value = httpx.Response(
status_code=200,
json={
"kind": "Project",
"metadata": {"name": "test-project", "guid": "mock_project_guid"},
}
},
)

response = await client.get_project("mock_project_guid")

assert isinstance(response, Munch)
assert response["metadata"]["guid"] == "mock_project_guid"



@pytest.mark.asyncio
async def test_update_project_success(client, mocker: AsyncMock):
async def test_update_project_success(client, mocker: AsyncMock): # noqa: F811
mock_put = mocker.patch("httpx.AsyncClient.put")

mock_put.return_value = httpx.Response(
status_code=200,
json={
"kind": "Project",
"metadata": {"name": "test-project", "guid": "mock_project_guid"},
}
},
)

response = await client.update_project("mock_project_guid", project_body)

assert isinstance(response, Munch)
assert response["metadata"]["guid"] == "mock_project_guid"



@pytest.mark.asyncio
async def test_delete_project_success(client, mocker: AsyncMock):
async def test_delete_project_success(client, mocker: AsyncMock): # noqa: F811
mock_delete = mocker.patch("httpx.AsyncClient.delete")

mock_delete.return_value = httpx.Response(
status_code=200,
json={"success": True}
)

mock_delete.return_value = httpx.Response(status_code=200, json={"success": True})

response = await client.delete_project("mock_project_guid")

assert isinstance(response, Munch)
assert response["success"] is True

0 comments on commit ca0d358

Please sign in to comment.