From e73233c90a87344814dd7f2858c06abf2e81209c Mon Sep 17 00:00:00 2001 From: ribardej Date: Wed, 12 Nov 2025 14:42:04 +0100 Subject: [PATCH] feat(docs): report.md update and refactored tests --- 7project/backend/tests/test_integration_app.py | 13 +------------ 7project/backend/tests/test_unit_user_service.py | 13 ++++++++++--- 7project/report.md | 6 +++--- 3 files changed, 14 insertions(+), 18 deletions(-) diff --git a/7project/backend/tests/test_integration_app.py b/7project/backend/tests/test_integration_app.py index 5806452..b37b495 100644 --- a/7project/backend/tests/test_integration_app.py +++ b/7project/backend/tests/test_integration_app.py @@ -3,17 +3,6 @@ import pytest from httpx import AsyncClient, ASGITransport -def test_root_ok(client): - resp = client.get("/") - assert resp.status_code == status.HTTP_200_OK - assert resp.json() == {"status": "ok"} - - -def test_authenticated_route_requires_auth(client): - resp = client.get("/authenticated-route") - assert resp.status_code in (status.HTTP_401_UNAUTHORIZED, status.HTTP_403_FORBIDDEN) - - @pytest.mark.asyncio async def test_create_and_get_category(fastapi_app, test_user): # Use AsyncClient for async tests @@ -165,6 +154,6 @@ async def test_delete_transaction_not_found(fastapi_app, test_user): async with AsyncClient(transport=transport, base_url="http://testserver") as ac: token = (await ac.post("/auth/jwt/login", data=test_user)).json()["access_token"] h = {"Authorization": f"Bearer {token}"} - r = await ac.delete("/transactions/999999/delete", headers=h) + r = await ac.delete("/transactions/9999999/delete", headers=h) assert r.status_code == status.HTTP_404_NOT_FOUND diff --git a/7project/backend/tests/test_unit_user_service.py b/7project/backend/tests/test_unit_user_service.py index dedff0e..311404d 100644 --- a/7project/backend/tests/test_unit_user_service.py +++ b/7project/backend/tests/test_unit_user_service.py @@ -1,7 +1,5 @@ -import types -import asyncio import pytest - +from fastapi import status from app.services import user_service @@ -22,6 +20,15 @@ def test_get_jwt_strategy_lifetime(): # Basic smoke check: strategy has a lifetime set to 604800 assert getattr(strategy, "lifetime_seconds", None) in (604800,) +def test_root_ok(client): + resp = client.get("/") + assert resp.status_code == status.HTTP_200_OK + assert resp.json() == {"status": "ok"} + + +def test_authenticated_route_requires_auth(client): + resp = client.get("/authenticated-route") + assert resp.status_code in (status.HTTP_401_UNAUTHORIZED, status.HTTP_403_FORBIDDEN) @pytest.mark.asyncio async def test_on_after_request_verify_enqueues_email(monkeypatch): diff --git a/7project/report.md b/7project/report.md index ba7b4a0..efd4c47 100644 --- a/7project/report.md +++ b/7project/report.md @@ -55,7 +55,7 @@ to a background worker service via the Message queue. - The stored transactions are encrypted in the DB for security reasons. - For every pull request the full APP is deployed on a separate URL and the tests are run by github CI/CD - On every push to main, the production app is automatically updated -- +- UI is responsive for mobile devices ### Components @@ -281,13 +281,13 @@ bash test-with-ephemeral-mariadb.sh ### Unit Tests -There are only 3 basic unit tests, since our services logic is very simple +There are only 5 basic unit tests, since our services logic is very simple ```bash bash test-with-ephemeral-mariadb.sh --only-unit ``` ### Integration Tests -There are 11 basic unit tests, testing the individual backend API logic +There are 9 basic unit tests, testing the individual backend API logic ```bash bash test-with-ephemeral-mariadb.sh --only-integration ```