Skip to content

Commit

Permalink
fix broken go live email notification
Browse files Browse the repository at this point in the history
  • Loading branch information
Kenneth Kehl committed Nov 27, 2024
1 parent 9b392af commit 6c0cbd2
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
1 change: 1 addition & 0 deletions app/service/sender.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ def send_notification_to_service_users(
template = dao_get_template_by_id(template_id)
service = dao_fetch_service_by_id(service_id)
active_users = dao_fetch_active_users_for_service(service.id)
print(hilite(f"ACTIVE USERS ARE {active_users}"))
notify_service = dao_fetch_service_by_id(current_app.config["NOTIFY_SERVICE_ID"])

for user in active_users:
Expand Down
10 changes: 9 additions & 1 deletion tests/app/service/test_sender.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import pytest
from flask import current_app
from app.utils import hilite
from sqlalchemy import func, select

from app import db
from app.dao.services_dao import dao_add_user_to_service
from app.dao.services_dao import dao_add_user_to_service, dao_fetch_active_users_for_service
from app.enums import NotificationType, TemplateType
from app.models import Notification
from app.service.sender import send_notification_to_service_users
Expand Down Expand Up @@ -91,8 +92,15 @@ def test_send_notification_to_service_users_sends_to_active_users_only(
second_active_user = create_user(email="[email protected]", state="active")
pending_user = create_user(email="[email protected]", state="pending")
service = create_service(user=first_active_user)
print(hilite(f"CREATED THE SERVICE {service} with user {first_active_user}"))
dao_add_user_to_service(service, second_active_user)
print(hilite(f"ADDED user {second_active_user}"))

dao_add_user_to_service(service, pending_user)
print(hilite(f"ADDED PENDING USER {pending_user}"))

active_users = dao_fetch_active_users_for_service(service.id)
print(hilite(f"ACTIVE USERS IN THE TEST {active_users}"))
template = create_template(service, template_type=TemplateType.EMAIL)

send_notification_to_service_users(service_id=service.id, template_id=template.id)
Expand Down

0 comments on commit 6c0cbd2

Please sign in to comment.