~homeworkprod/byceps

9d35912283fad59ad3a4e70f2aead7206f0d890f — Jochen Kupperschmidt 10 months ago 087d94c
Create email config on brand creation via admin UI

From now on, each brand is expected to have an email configuration.
M byceps/blueprints/admin/brand/views.py => byceps/blueprints/admin/brand/views.py +7 -0
@@ 94,6 94,13 @@ def create():

    brand = brand_service.create_brand(brand_id, title)

    email_service.create_config(
        brand.id,
        sender_address=f'noreply@{brand.id}.example',
        sender_name=brand.title,
        contact_address=f'info@{brand.id}.example',
    )

    flash_success(f'Die Marke "{brand.title}" wurde angelegt.')
    return redirect_to('.index')


M tests/integration/blueprints/admin/brand/test_views.py => tests/integration/blueprints/admin/brand/test_views.py +9 -0
@@ 4,6 4,7 @@
"""

import byceps.services.brand.service as brand_service
import byceps.services.email.service as email_service


def test_index(brand_admin_client, brand):


@@ 42,7 43,15 @@ def test_create(brand_admin_client):
    assert brand.id == brand_id
    assert brand.title == title

    email_config = email_service.find_config(brand.id)
    assert email_config is not None
    assert email_config.sender is not None
    assert email_config.sender.address == 'noreply@galant.example'
    assert email_config.sender.name == 'gaLANt'
    assert email_config.contact_address == 'info@galant.example'

    # Clean up.
    email_service.delete_config(brand_id)
    brand_service.delete_brand(brand_id)