def test_get_html_email_renderer_with_branding_details(
        branding_type,
        default_banner,
        sample_notification_model_with_organization,
        mock_email_client
):

    email_branding = EmailBranding(
        brand_type=branding_type,
        colour='#000000',
        logo='justice-league.png',
        name='Justice League',
        text='League of Justice',
    )
    sample_notification_model_with_organization.service.email_branding = email_branding

    options = send_to_providers.get_html_email_options(
        sample_notification_model_with_organization,
        mock_email_client
    )

    assert options['default_banner'] == default_banner
    assert options['brand_colour'] == '#000000'
    assert options['brand_text'] == 'League of Justice'
    assert options['brand_name'] == 'Justice League'

    if branding_type == BRANDING_ORG_BANNER:
        assert options['brand_banner'] is True
    else:
        assert options['brand_banner'] is False
def test_get_html_email_renderer_with_branding_details(branding_type,
                                                       govuk_banner, notify_db,
                                                       sample_service):

    email_branding = EmailBranding(
        brand_type=branding_type,
        colour='#000000',
        logo='justice-league.png',
        name='Justice League',
        text='League of Justice',
    )
    sample_service.email_branding = email_branding
    notify_db.session.add_all([sample_service, email_branding])
    notify_db.session.commit()

    options = send_to_providers.get_html_email_options(sample_service)

    assert options['govuk_banner'] == govuk_banner
    assert options['brand_colour'] == '#000000'
    assert options['brand_text'] == 'League of Justice'
    assert options['brand_name'] == 'Justice League'

    if branding_type == BRANDING_ORG_BANNER:
        assert options['brand_banner'] is True
    else:
        assert options['brand_banner'] is False
def test_get_html_email_renderer_with_branding_details(
    branding_type, fip_banner_english, fip_banner_french, notify_db, sample_service
):

    email_branding = EmailBranding(
        brand_type=branding_type,
        colour="#000000",
        logo="justice-league.png",
        name="Justice League",
        text="League of Justice",
    )
    sample_service.email_branding = email_branding
    notify_db.session.add_all([sample_service, email_branding])
    notify_db.session.commit()

    options = send_to_providers.get_html_email_options(sample_service)

    assert options["fip_banner_english"] == fip_banner_english
    assert options["fip_banner_french"] == fip_banner_french
    assert options["brand_colour"] == "#000000"
    assert options["brand_text"] == "League of Justice"
    assert options["brand_name"] == "Justice League"

    if branding_type == BRANDING_ORG_BANNER_NEW:
        assert options["logo_with_background_colour"] is True
    else:
        assert options["logo_with_background_colour"] is False
예제 #4
0
def test_get_html_email_renderer_should_return_for_normal_service(
        sample_service):
    options = send_to_providers.get_html_email_options(sample_service)
    assert options['govau_banner']
    assert 'brand_colour' not in options.keys()
    assert 'brand_logo' not in options.keys()
    assert 'brand_name' not in options.keys()
예제 #5
0
def test_get_html_email_renderer_with_branding_details_and_render_govuk_banner_only(notify_db, sample_service):
    sample_service.email_branding = None
    notify_db.session.add_all([sample_service])
    notify_db.session.commit()

    options = send_to_providers.get_html_email_options(sample_service)

    assert options == {'govuk_banner': True, 'brand_banner': False}
def test_get_html_email_renderer_should_return_for_normal_service(sample_service):
    options = send_to_providers.get_html_email_options(sample_service)
    assert options["fip_banner_english"] is True
    assert options["fip_banner_french"] is False
    assert "brand_colour" not in options.keys()
    assert "brand_logo" not in options.keys()
    assert "brand_text" not in options.keys()
    assert "brand_name" not in options.keys()
def test_get_html_email_renderer_prepends_logo_path(notify_db, sample_service):
    sample_service.branding = BRANDING_ORG
    org = Organisation(colour='#000000', logo='justice-league.png', name='Justice League')
    sample_service.organisation = org
    notify_db.session.add_all([sample_service, org])
    notify_db.session.commit()

    renderer = send_to_providers.get_html_email_options(sample_service)

    assert renderer['brand_logo'] == 'http://localhost:6012/static/images/email-template/crests/justice-league.png'
예제 #8
0
def test_get_html_email_renderer_should_return_for_normal_service(
        sample_notification_model_with_organization, mock_email_client):
    options = send_to_providers.get_html_email_options(
        sample_notification_model_with_organization, mock_email_client)
    assert options['default_banner'] is True
    assert 'brand_colour' not in options.keys()
    assert 'brand_logo' not in options.keys()
    assert 'brand_text' not in options.keys()
    assert 'brand_name' not in options.keys()
    assert 'ga_pixel_url' in options.keys()
예제 #9
0
def test_get_html_email_renderer_with_branding_details_and_render_default_banner_only(
        sample_notification_model_with_organization, mock_email_client):
    sample_notification_model_with_organization.service.email_branding = None

    options = send_to_providers.get_html_email_options(
        sample_notification_model_with_organization, mock_email_client)

    assert {
        'default_banner': True,
        'brand_banner': False
    }.items() <= options.items()
def test_get_html_email_renderer_with_branding_details(branding_type, govuk_banner, notify_db, sample_service):
    sample_service.branding = branding_type
    org = Organisation(colour='#000000', logo='justice-league.png', name='Justice League')
    sample_service.organisation = org
    notify_db.session.add_all([sample_service, org])
    notify_db.session.commit()

    options = send_to_providers.get_html_email_options(sample_service)

    assert options['govuk_banner'] == govuk_banner
    assert options['brand_colour'] == '#000000'
    assert options['brand_name'] == 'Justice League'
def test_get_html_email_renderer_with_branding_details_and_render_fip_banner_english_only(notify_db, sample_service):
    sample_service.email_branding = None
    notify_db.session.add_all([sample_service])
    notify_db.session.commit()

    options = send_to_providers.get_html_email_options(sample_service)

    assert options == {
        "fip_banner_english": True,
        "fip_banner_french": False,
        "logo_with_background_colour": False,
    }
예제 #12
0
def test_get_html_email_renderer_handles_email_branding_without_logo(
        notify_api):
    Service = namedtuple('Service', ['branding', 'email_branding'])
    EmailBranding = namedtuple('EmailBranding', ['colour', 'name', 'logo'])

    email_branding = EmailBranding(colour='#000000',
                                   logo=None,
                                   name='Justice League')
    service = Service(branding=BRANDING_ORG, email_branding=email_branding)

    renderer = send_to_providers.get_html_email_options(service)

    assert renderer['brand_logo'] is None
예제 #13
0
def test_get_html_email_renderer_prepends_logo_path(notify_api):
    Service = namedtuple('Service', ['branding', 'email_branding'])
    EmailBranding = namedtuple('EmailBranding', ['colour', 'name', 'logo'])

    email_branding = EmailBranding(colour='#000000',
                                   logo='justice-league.png',
                                   name='Justice League')
    service = Service(branding=BRANDING_ORG, email_branding=email_branding)

    renderer = send_to_providers.get_html_email_options(service)

    assert renderer[
        'brand_logo'] == 'https://notify-static-logos-staging.static.cld.gov.au/justice-league.png'
예제 #14
0
def test_get_html_email_renderer_with_branding_details_and_render_govau_banner_only(
        notify_db, sample_service):
    sample_service.branding = BRANDING_GOVAU
    email_branding = EmailBranding(colour='#000000',
                                   logo='justice-league.png',
                                   name='Justice League')
    sample_service.email_branding = email_branding
    notify_db.session.add_all([sample_service, email_branding])
    notify_db.session.commit()

    options = send_to_providers.get_html_email_options(sample_service)

    assert options == {'govau_banner': True, 'brand_banner': False}
def test_get_html_email_renderer_prepends_logo_path(
        notify_api,
        sample_notification_model_with_organization,
        mock_email_client
):
    email_branding = EmailBranding(
        brand_type=BRANDING_ORG,
        colour='#000000',
        logo='justice-league.png',
        name='Justice League',
        text='League of Justice',
    )
    sample_notification_model_with_organization.service.email_branding = email_branding

    renderer = send_to_providers.get_html_email_options(sample_notification_model_with_organization, mock_email_client)
    domain = "https://dev-notifications-va-gov-assets.s3.amazonaws.com"
    assert renderer['brand_logo'] == "{}{}".format(domain, '/justice-league.png')
def test_get_html_email_renderer_prepends_logo_path(notify_api):
    Service = namedtuple("Service", ["email_branding"])
    EmailBranding = namedtuple("EmailBranding", ["brand_type", "colour", "name", "logo", "text"])

    email_branding = EmailBranding(
        brand_type=BRANDING_ORG_NEW,
        colour="#000000",
        logo="justice-league.png",
        name="Justice League",
        text="League of Justice",
    )
    service = Service(
        email_branding=email_branding,
    )

    renderer = send_to_providers.get_html_email_options(service)
    domain = "https://assets.notification.canada.ca"
    assert renderer["brand_logo"] == "{}{}".format(domain, "/justice-league.png")
def test_get_html_email_renderer_prepends_logo_path(notify_api):
    Service = namedtuple('Service', ['email_branding'])
    EmailBranding = namedtuple(
        'EmailBranding', ['brand_type', 'colour', 'name', 'logo', 'text'])

    email_branding = EmailBranding(
        brand_type=BRANDING_ORG,
        colour='#000000',
        logo='justice-league.png',
        name='Justice League',
        text='League of Justice',
    )
    service = Service(email_branding=email_branding, )

    renderer = send_to_providers.get_html_email_options(service)

    assert renderer[
        'brand_logo'] == 'http://static-logos.notify.tools/justice-league.png'
예제 #18
0
def test_get_html_email_renderer_prepends_logo_path(notify_api):
    Service = namedtuple('Service', ['email_branding'])
    EmailBranding = namedtuple(
        'EmailBranding', ['brand_type', 'colour', 'name', 'logo', 'text'])

    email_branding = EmailBranding(
        brand_type=BRANDING_ORG_NEW,
        colour='#000000',
        logo='justice-league.png',
        name='Justice League',
        text='League of Justice',
    )
    service = Service(email_branding=email_branding, )

    renderer = send_to_providers.get_html_email_options(service)
    domain = "https://assets.notification.canada.ca"
    assert renderer['brand_logo'] == "{}{}".format(domain,
                                                   '/justice-league.png')
def test_get_html_email_options_add_email_branding_from_service(
        sample_service):
    branding = create_email_branding()
    sample_service.email_branding = branding
    email_options = get_html_email_options(sample_service)
    assert email_options is not None
    assert email_options == {
        'govuk_banner':
        branding.brand_type == BRANDING_BOTH,
        'brand_banner':
        branding.brand_type == BRANDING_ORG_BANNER,
        'brand_colour':
        branding.colour,
        'brand_logo':
        get_logo_url(current_app.config['ADMIN_BASE_URL'], branding.logo),
        'brand_text':
        branding.text,
        'brand_name':
        branding.name,
    }
예제 #20
0
def test_get_html_email_renderer_handles_email_branding_without_logo(
        notify_api, sample_notification_model_with_organization,
        mock_email_client):
    email_branding = EmailBranding(
        brand_type=BRANDING_ORG_BANNER,
        colour='#000000',
        logo=None,
        name='Justice League',
        text='League of Justice',
    )

    sample_notification_model_with_organization.service.email_branding = email_branding

    renderer = send_to_providers.get_html_email_options(
        sample_notification_model_with_organization, mock_email_client)

    assert renderer['default_banner'] is False
    assert renderer['brand_banner'] is True
    assert renderer['brand_logo'] is None
    assert renderer['brand_text'] == 'League of Justice'
    assert renderer['brand_colour'] == '#000000'
    assert renderer['brand_name'] == 'Justice League'
def test_get_html_email_renderer_handles_email_branding_without_logo(notify_api):
    Service = namedtuple("Service", ["email_branding"])
    EmailBranding = namedtuple("EmailBranding", ["brand_type", "colour", "name", "logo", "text"])

    email_branding = EmailBranding(
        brand_type=BRANDING_ORG_BANNER_NEW,
        colour="#000000",
        logo=None,
        name="Justice League",
        text="League of Justice",
    )
    service = Service(
        email_branding=email_branding,
    )

    renderer = send_to_providers.get_html_email_options(service)

    assert renderer["fip_banner_english"] is False
    assert renderer["logo_with_background_colour"] is True
    assert renderer["brand_logo"] is None
    assert renderer["brand_text"] == "League of Justice"
    assert renderer["brand_colour"] == "#000000"
    assert renderer["brand_name"] == "Justice League"
def test_get_html_email_renderer_handles_email_branding_without_logo(
        notify_api):
    Service = namedtuple('Service', ['email_branding'])
    EmailBranding = namedtuple(
        'EmailBranding', ['brand_type', 'colour', 'name', 'logo', 'text'])

    email_branding = EmailBranding(
        brand_type=BRANDING_ORG_BANNER,
        colour='#000000',
        logo=None,
        name='Justice League',
        text='League of Justice',
    )
    service = Service(email_branding=email_branding, )

    renderer = send_to_providers.get_html_email_options(service)

    assert renderer['govuk_banner'] is False
    assert renderer['brand_banner'] is True
    assert renderer['brand_logo'] is None
    assert renderer['brand_text'] == 'League of Justice'
    assert renderer['brand_colour'] == '#000000'
    assert renderer['brand_name'] == 'Justice League'
def test_get_html_email_renderer_should_return_for_normal_service(sample_service):
    options = send_to_providers.get_html_email_options(sample_service)
    assert options['govuk_banner']
    assert 'brand_colour' not in options.keys()
    assert 'brand_logo' not in options.keys()
    assert 'brand_name' not in options.keys()