Exemplo n.º 1
0
def test_insufficient_funds(urlopen, Request):
    resp = mock.Mock()
    resp.read.return_value = '{"status": "error", "error": "insufficient funds"}'
    urlopen.side_effect = urllib2.HTTPError('', 402, 'payment required', {'Content-Type': 'application/json'}, resp)

    n = Notifout('123')
    n.send('tpl1', '*****@*****.**')

    Request.assert_called_once_with('https://notifout.com/api/send', 
                                    '{"token": "123", "messages": [{"data": null, "recipient": "*****@*****.**", "sender": null, "template": "tpl1", "subject": null}]}', 
                                    headers={'Content-Type': 'application/json'})
    ok_(urlopen.called)    
Exemplo n.º 2
0
def test_normal_send(urlopen, Request):
    resp = mock.Mock()
    resp.headers={'Content-Type': 'application/json'}
    resp.read.return_value = '{"status": "accepted"}'
    urlopen.return_value = resp

    n = Notifout('123')
    n.send('tpl1', '*****@*****.**')

    Request.assert_called_once_with('https://notifout.com/api/send', 
                                    '{"token": "123", "messages": [{"data": null, "recipient": "*****@*****.**", "sender": null, "template": "tpl1", "subject": null}]}', 
                                    headers={'Content-Type': 'application/json'})
    ok_(urlopen.called)