How to use the sparkpost.Transmissions function in sparkpost

To help you get started, we’ve selected a few sparkpost examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github SparkPost / python-sparkpost / test / test_transmissions.py View on Github external
def test_translate_keys_with_multiple_cc():
    t = Transmissions('uri', 'key')
    results = t._translate_keys(recipients=['primary@example.com'],
                                cc=['ccone@example.com', 'cctwo@example.com'])
    assert results['recipients'] == [
        {'address': {'email': 'primary@example.com'}},
        {'address': {'email': 'ccone@example.com',
                     'header_to': 'primary@example.com'}},
        {'address': {'email': 'cctwo@example.com',
                     'header_to': 'primary@example.com'}},
    ]
    assert results['content']['headers'] == {
        'CC': 'ccone@example.com,cctwo@example.com'
    }
github SparkPost / python-sparkpost / test / test_transmissions.py View on Github external
def test_cc_with_sub_data():
    t = Transmissions('uri', 'key')
    results = t._translate_keys(
        recipients=[{
            'address': {'email': 'primary@example.com'},
            'substitution_data': {'fake': 'data'}
        }],
        cc=['ccone@example.com']
    )
    assert results['recipients'] == [
        {
            'address': {'email': 'primary@example.com'},
            'substitution_data': {'fake': 'data'}
        },
        {
            'address': {
                'email': 'ccone@example.com',
                'header_to': 'primary@example.com'
github SparkPost / python-sparkpost / test / test_transmissions.py View on Github external
def test_translate_keys_with_recips():
    t = Transmissions('uri', 'key')
    results = t._translate_keys(recipients=['test',
                                            {'key': 'value'}, 'foobar'])
    assert results['recipients'] == [{'address': {'email': 'test'}},
                                     {'key': 'value'},
                                     {'address': {'email': 'foobar'}}]
github SparkPost / python-sparkpost / test / test_transmissions.py View on Github external
def test_format_header_to():
    t = Transmissions('uri', 'key')
    formatted = t._format_header_to(recipient={
        'address': {'email': 'primary@example.com'}
    })
    assert formatted == 'primary@example.com'

    formatted = t._format_header_to(recipient={
        'address': {'name': 'Testing', 'email': 'primary@example.com'}
    })
    assert formatted == '"Testing" '
github SparkPost / python-sparkpost / test / test_transmissions.py View on Github external
def test_translate_keys_with_bcc():
    t = Transmissions('uri', 'key')
    results = t._translate_keys(recipients=['primary@example.com'],
                                bcc=['bccone@example.com'])
    assert results['recipients'] == [
        {'address': {'email': 'primary@example.com'}},
        {'address': {'email': 'bccone@example.com',
                     'header_to': 'primary@example.com'}},
    ]
github SparkPost / python-sparkpost / test / test_transmissions.py View on Github external
def test_translate_keys_for_email_parsing():
    t = Transmissions('uri', 'key')
    results = t._translate_keys(recipients=['hansel@example.com',
                                            'Gretel '])
    assert results['recipients'] == [
        {'address': {'email': 'hansel@example.com'}},
        {'address': {'name': 'Gretel', 'email': 'gretel@example.com'}}
    ]
github SparkPost / python-sparkpost / test / test_transmissions.py View on Github external
def test_translate_keys_with_cc():
    t = Transmissions('uri', 'key')
    results = t._translate_keys(recipients=['primary@example.com'],
                                cc=['ccone@example.com'])
    assert results['recipients'] == [
        {'address': {'email': 'primary@example.com'}},
        {'address': {'email': 'ccone@example.com',
                     'header_to': 'primary@example.com'}},
    ]
    assert results['content']['headers'] == {
        'CC': 'ccone@example.com'
    }
github SparkPost / python-sparkpost / test / test_transmissions.py View on Github external
def test_translate_keys_with_inline_css():
    t = Transmissions('uri', 'key')
    results = t._translate_keys(inline_css=True)
    assert results['options'].get('inline_css') is True
github SparkPost / python-sparkpost / test / test_transmissions.py View on Github external
def test_translate_keys_with_email_rfc822():
    t = Transmissions('uri', 'key')

    # Build data using implicit cat, as max line length is enforced
    eml = (
        'To: wilma \n',
        'From: fred \n',
        'Subject: Bedrock declaration\n',
        'MIME-Version: 1.0\n',
        'Content-Type: text/plain; charset=utf-8; format=flowed\n',
        'Content-Transfer-Encoding: 7bit\nContent-Language: en-GB\n',
        '\n',
        'When in the Course of human events we yell yabba dabba doo.',
    )

    # Just a selection. Don't test attribs with irregular naming
    non_rfc822_attrs = {
        'headers': 'foo',
github SparkPost / python-sparkpost / test / test_transmissions.py View on Github external
def test_exceptions_for_recipients():
    t = Transmissions('uri', 'key')
    with pytest.raises(SparkPostException):
        t._translate_keys(recipients='test')