Example #1
0
def test_get_payload_with_messages(url, service_match):
    slack = SlackNotification(url, service_match)

    messages = (
        ('foo', 'bar'),
        ('lorem', 'ipsum'),
    )

    payload = slack.get_payload('Foobar', messages, 'good')

    expected = {
        'username':
        '******',
        'attachments': [{
            'color':
            'good',
            'pretext':
            'Foobar',
            'fields': [{
                'short': True,
                'title': 'foo',
                'value': 'bar'
            }, {
                'short': True,
                'title': 'lorem',
                'value': 'ipsum'
            }],
        }],
    }

    assert payload == expected
Example #2
0
def test_get_payload_without_messages(url, service_match):
    slack = SlackNotification(url, service_match)

    payload = slack.get_payload('Foobar', [], 'good')

    expected = {
        'username': '******',
        'attachments': [{
            'color': 'good',
            'pretext': 'Foobar',
            'fields': [],
        }],
    }

    assert payload == expected