def render_email_template(results):
    """Return populated text that can be sent as an email summary of the item/location results.

    Inputs:
        results (dict) --  Two-dimensional dictionary containing search keywords (keys) and location search results (key, value pairs).

    Returns:
        str -- Summary of results in HTML format.
    """
    with open(
            'ebay_multilocation_item_notifier/templates/notification-email.html'
    ) as fp:
        template = JinjaTemplate(fp.read())

    return template.render(results=results)
예제 #2
0
def test_render_message_with_template():
    TEMPLATE = JinjaTemplate('Hello, {{name}}!')
    V = dict(name='world')
    RESULT = TEMPLATE.render(**V)
    assert RESULT == 'Hello, world!'

    msg = emails.html(subject=TEMPLATE)
    msg.render(**V)
    assert msg.subject == RESULT

    msg = emails.html(html=TEMPLATE)
    msg.render(**V)
    assert msg.html_body == RESULT

    msg = emails.html(text=TEMPLATE)
    msg.render(**V)
    assert msg.text_body == RESULT