Compare commits

3 Commits

Author SHA1 Message Date
c689caea88 refactor(core): fix tests 2025-11-14 16:51:21 +01:00
8c20deb690 refactor(core): simplify core module 2025-11-14 16:42:35 +01:00
39979b51ee update report 2025-11-14 15:20:16 +01:00
5 changed files with 16 additions and 17 deletions

View File

@@ -656,6 +656,11 @@ FastAPI lacks usable build in support for database migrations and implementing A
Tricky was also integrating FastAPI auth system with React frontend, since there is no official project template. Tricky was also integrating FastAPI auth system with React frontend, since there is no official project template.
Using .NET (which we considered initially) would probably solve these issues. Using .NET (which we considered initially) would probably solve these issues.
#### Private container registry
Using private container registry would allow us to include environment variables directly in the image during build.
This would simplify deployment and CI/CD setup.
[What would you do differently? What worked well that you'd keep?] [What would you do differently? What worked well that you'd keep?]
### Individual Growth ### Individual Growth

View File

@@ -1,6 +0,0 @@
import app.celery_app # noqa: F401
from app.workers.celery_tasks import send_email
def enqueue_email(to: str, subject: str, body: str) -> None:
send_email.delay(to, subject, body)

View File

@@ -14,11 +14,10 @@ from httpx_oauth.oauth2 import BaseOAuth2
from app.models.user import User from app.models.user import User
from app.oauth.bank_id import BankID from app.oauth.bank_id import BankID
from app.oauth.csas import CSASOAuth from app.workers.celery_tasks import send_email
from app.oauth.custom_openid import CustomOpenID from app.oauth.custom_openid import CustomOpenID
from app.oauth.moje_id import MojeIDOAuth from app.oauth.moje_id import MojeIDOAuth
from app.services.db import get_user_db from app.services.db import get_user_db
from app.core.queue import enqueue_email
SECRET = os.getenv("SECRET", "CHANGE_ME_SECRET") SECRET = os.getenv("SECRET", "CHANGE_ME_SECRET")
@@ -87,7 +86,7 @@ class UserManager(UUIDIDMixin, BaseUserManager[User, uuid.UUID]):
"Pokud jsi registraci neprováděl(a), tento email ignoruj.\n" "Pokud jsi registraci neprováděl(a), tento email ignoruj.\n"
) )
try: try:
enqueue_email(to=user.email, subject=subject, body=body) send_email.delay(user.email, subject, body)
except Exception as e: except Exception as e:
print("[Email Fallback] To:", user.email) print("[Email Fallback] To:", user.email)
print("[Email Fallback] Subject:", subject) print("[Email Fallback] Subject:", subject)

View File

@@ -34,7 +34,8 @@ def test_authenticated_route_requires_auth(client):
async def test_on_after_request_verify_enqueues_email(monkeypatch): async def test_on_after_request_verify_enqueues_email(monkeypatch):
calls = {} calls = {}
def fake_enqueue_email(to: str, subject: str, body: str): class FakeCeleryTask:
def delay(to: str, subject: str, body: str):
calls.setdefault("emails", []).append({ calls.setdefault("emails", []).append({
"to": to, "to": to,
"subject": subject, "subject": subject,
@@ -42,7 +43,7 @@ async def test_on_after_request_verify_enqueues_email(monkeypatch):
}) })
# Patch the enqueue_email used inside user_service # Patch the enqueue_email used inside user_service
monkeypatch.setattr(user_service, "enqueue_email", fake_enqueue_email) monkeypatch.setattr(user_service, "send_email", FakeCeleryTask)
class DummyUser: class DummyUser:
def __init__(self, email): def __init__(self, email):