def load_dummy_context(): berth_lease = BerthLeaseFactory.build() ws_lease = WinterStorageLeaseFactory.build() dummy_context.update({ NotificationType.AUTOMATIC_INVOICING_EMAIL_ADMINS: { "subject": NotificationType.AUTOMATIC_INVOICING_EMAIL_ADMINS.label, "exited_with_errors": False, "successful_orders": randint(100, 500), "failed_orders": randint(0, 10), }, NotificationType.BERTH_LEASE_TERMINATED_LEASE_NOTICE: { "subject": NotificationType.BERTH_LEASE_TERMINATED_LEASE_NOTICE.label, "cancelled_at": format_date(today(), locale="fi"), "lease": berth_lease, }, NotificationType.WINTER_STORAGE_LEASE_TERMINATED_LEASE_NOTICE: { "subject": NotificationType.WINTER_STORAGE_LEASE_TERMINATED_LEASE_NOTICE. label, "cancelled_at": format_date(today(), locale="fi"), "lease": ws_lease, }, })
def load_dummy_context(): dummy_context.update({ NotificationType.NEW_BERTH_ORDER_APPROVED: _get_berth_order_context( get_email_subject(NotificationType.NEW_BERTH_ORDER_APPROVED)), NotificationType.RENEW_BERTH_ORDER_APPROVED: _get_berth_order_context( get_email_subject(NotificationType.RENEW_BERTH_ORDER_APPROVED)), NotificationType.BERTH_SWITCH_OFFER_APPROVED: _get_berth_order_context( get_email_subject(NotificationType.BERTH_SWITCH_OFFER_APPROVED)), NotificationType.NEW_WINTER_STORAGE_ORDER_APPROVED: _get_winter_storage_order_context( get_email_subject( NotificationType.NEW_WINTER_STORAGE_ORDER_APPROVED)), NotificationType.UNMARKED_WINTER_STORAGE_ORDER_APPROVED: _get_winter_storage_order_context( get_email_subject( NotificationType.UNMARKED_WINTER_STORAGE_ORDER_APPROVED)), NotificationType.ADDITIONAL_PRODUCT_ORDER_APPROVED: _get_additional_product_order_context( get_email_subject( NotificationType.ADDITIONAL_PRODUCT_ORDER_APPROVED)), NotificationType.ORDER_CANCELLED: _get_cancelled_order_context( get_email_subject(NotificationType.ORDER_CANCELLED)), NotificationType.ORDER_REFUNDED: _get_refunded_order_context( get_email_subject(NotificationType.ORDER_REFUNDED)), NotificationType.BERTH_SWITCH_OFFER_APPROVED: _get_berth_switch_offer_context( get_email_subject(NotificationType.BERTH_SWITCH_OFFER_APPROVED)), NotificationType.SMS_INVOICE_NOTICE: { "product_name": "Berth", "due_date": str(today()), "payment_url": "https://foo.bar/payment", }, NotificationType.SMS_BERTH_SWITCH_NOTICE: { "due_date": str(today()), "accept_url": "https://foo.bar/payment", }, })
def load_dummy_context(): berth_application = BerthApplicationFactory.build() harbor_choices = HarborChoiceFactory.build_batch( size=3, application=berth_application) winter_storage_application = WinterStorageApplicationFactory.build() winter_area_choices = WinterAreaChoiceFactory.build_batch( size=3, application=winter_storage_application) dummy_context.update({ COMMON_CONTEXT: { "created_at": format_date(today(), locale="fi") }, NotificationType.BERTH_APPLICATION_CREATED: { "subject": NotificationType.BERTH_APPLICATION_CREATED.label, "application": berth_application, "harbor_choices": sorted(harbor_choices, key=lambda c: c.priority), }, NotificationType.BERTH_APPLICATION_REJECTED: { "subject": NotificationType.BERTH_APPLICATION_REJECTED.label, "application": berth_application, "harbor_choices": sorted(harbor_choices, key=lambda c: c.priority), }, NotificationType.WINTER_STORAGE_APPLICATION_CREATED: { "subject": NotificationType.WINTER_STORAGE_APPLICATION_CREATED.label, "application": winter_storage_application, "area_choices": sorted(winter_area_choices, key=lambda c: c.priority), }, NotificationType.UNMARKED_WINTER_STORAGE_APPLICATION_CREATED: { "subject": NotificationType.UNMARKED_WINTER_STORAGE_APPLICATION_CREATED.label, "application": winter_storage_application, "area_choices": sorted(winter_area_choices, key=lambda c: c.priority), }, })
from .enums import NotificationType notifications.register( NotificationType.YOUTH_PROFILE_CONFIRMATION_NEEDED.value, NotificationType.YOUTH_PROFILE_CONFIRMATION_NEEDED.label, ) notifications.register( NotificationType.YOUTH_PROFILE_CONFIRMED.value, NotificationType.YOUTH_PROFILE_CONFIRMED.label, ) dummy_context.update({ COMMON_CONTEXT: { "youth_name": "YOUTH NAME", "youth_profile": { "approver_first_name": "APPROVER FIRST NAME" }, "youth_membership_ui_base_url": settings.EMAIL_TEMPLATE_YOUTH_MEMBERSHIP_UI_BASE_URL, }, NotificationType.YOUTH_PROFILE_CONFIRMATION_NEEDED.value: { "youth_profile": { "approver_first_name": "APPROVER FIRST NAME", "approval_token": "approval_token", "profile_access_token": "profile_access_token", } }, })
from django.utils import timezone from django.utils.translation import gettext_lazy as _ from django_ilmoitin.dummy_context import COMMON_CONTEXT, dummy_context from django_ilmoitin.registry import notifications from unittest.mock import MagicMock from apartment_application_service.consts import NotificationType # This module and django-ilmoitin might be redundant if the notification system is # later replaced with Helsinki Profiili email service when that releases. TEMPLATES = [ (NotificationType.APPLICATION_CREATED, _("Application created")), ] for template in TEMPLATES: notifications.register(template[0], template[1]) dummy_context.update( { COMMON_CONTEXT: {"created_at": timezone.now()}, # TODO: pass more appropriate in-memory objects NotificationType.APPLICATION_CREATED: MagicMock(), } )
from django_ilmoitin.dummy_context import COMMON_CONTEXT, dummy_context from .models import Animal dummy_animal = Animal(name="unicorn") dummy_context.update( {COMMON_CONTEXT: {"animal": dummy_animal},} )