From 333ae47d8c4e8aae2dc5f05d22a0462281e74366 Mon Sep 17 00:00:00 2001 From: yvonne Date: Mon, 8 Dec 2025 19:32:20 +0100 Subject: [PATCH 1/2] introduce bug --- app/main.py | 2 +- trainings-tasks/00_prerequists_intro.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/main.py b/app/main.py index fecf5e2..15621fa 100644 --- a/app/main.py +++ b/app/main.py @@ -61,7 +61,7 @@ async def generate_productivity_report() -> ProductivityReport: app = FastAPI(title="Productivity Reporting System") @app.get("/status") -def get_status(): +def get_status() return {"status": "ok"} diff --git a/trainings-tasks/00_prerequists_intro.md b/trainings-tasks/00_prerequists_intro.md index 7792be2..cbe6fe4 100644 --- a/trainings-tasks/00_prerequists_intro.md +++ b/trainings-tasks/00_prerequists_intro.md @@ -19,7 +19,7 @@ To ensure a smooth session, please ensure the following items are verified befor - **Visual Studio Code**: Recommended to use latest stable VS Code. - **Required Extensions**: Install the [GitHub Copilot](https://marketplace.visualstudio.com/items?itemName=GitHub.copilot) and [GitHub Pull Requests & Issues](https://marketplace.visualstudio.com/items?itemName=GitHub.vscode-pull-request-github) extensions in VS Code. - **`uv` Package Manager**: The `uv` utility is required for fast environment and dependency management: [uv Installation Guide](https://docs.astral.sh/uv/getting-started/installation/) -- **Code Base**: Fork the [course repository](https://github.com/YvFrey/training-github-copilot/tree/main) to your own GitHub account. Clone **your project** locally. This setup ensures you have all necessary permissions in Github when running your custom agents. +- **Code Base**: Fork the [course repository](https://github.com/YvFrey/github-copilot-training.git) to your own GitHub account. Clone **your project** locally. This setup ensures you have all necessary permissions in Github when running your custom agents. ### ⚠️ Important: Feature Alignment and Version Check From 2dae4ca2d6a5aafc98372182bcd3b765b984e2a2 Mon Sep 17 00:00:00 2001 From: leonaIstrefi25 Date: Wed, 18 Mar 2026 16:16:01 +0100 Subject: [PATCH 2/2] add TaskCompletionMetrics model and integration tests for task status --- app/models.py | 19 ++++++++++++++++ tests/integration/test_main.py | 41 ++++++++++++++++++++++++++++++++++ 2 files changed, 60 insertions(+) create mode 100644 app/models.py create mode 100644 tests/integration/test_main.py diff --git a/app/models.py b/app/models.py new file mode 100644 index 0000000..9344906 --- /dev/null +++ b/app/models.py @@ -0,0 +1,19 @@ +from pydantic import BaseModel, Field + +class TaskCompletionMetrics(BaseModel): + """Model representing task completion metrics.""" + + total_tasks: int = Field(..., ge=0, description="Total number of tasks") + completed_tasks: int = Field(..., ge=0, description="Number of completed tasks") + completion_percentage: float = Field(..., ge=0, le=100, description="Completion percentage (0-100)") + pending_tasks: int = Field(..., ge=0, description="Number of pending tasks") + + class Config: + json_schema_extra = { + "example": { + "total_tasks": 10, + "completed_tasks": 7, + "completion_percentage": 70.0, + "pending_tasks": 3, + } + } \ No newline at end of file diff --git a/tests/integration/test_main.py b/tests/integration/test_main.py new file mode 100644 index 0000000..21ad4ae --- /dev/null +++ b/tests/integration/test_main.py @@ -0,0 +1,41 @@ +import pytest +from httpx import AsyncClient +from app.main import app + +@pytest.mark.asyncio +@pytest.mark.integration +async def test_get_task_status_existing_task_returns_status() -> None: +async with AsyncClient(app=app, base_url="http://test") as client: +resp = await client.get("/task/1/status") +assert resp.status_code == 200 +body = resp.json() +assert body["task_id"] == "1" +assert body["status"] in {"pending", "in_progress", "complete"} +@pytest.mark.asyncio +@pytest.mark.integration +async def test_get_task_status_unknown_task_returns_404() -> None: +async with AsyncClient(app=app, base_url="http://test") as client: +resp = await client.get("/task/999/status") +assert resp.status_code == 404 +assert resp.json()["detail"] == "Task not found" + + +@pytest.fixture +async def task_fixture() -> dict: + """Fixture to create a test task before each test.""" + async with AsyncClient(app=app, base_url="http://test") as client: + response = await client.post("/task", json={"title": "Test Task"}) + assert response.status_code == 201 + return response.json() + + +@pytest.mark.asyncio +@pytest.mark.integration +async def test_get_task_status_existing_task_with_fixture(task_fixture: dict) -> None: + task_id = task_fixture["task_id"] + async with AsyncClient(app=app, base_url="http://test") as client: + resp = await client.get(f"/task/{task_id}/status") + assert resp.status_code == 200 + body = resp.json() + assert body["task_id"] == str(task_id) + assert body["status"] in {"pending", "in_progress", "complete"} \ No newline at end of file