1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96
|
# -*- coding: utf-8 -*-
from exotel import Exotel
def test_sms(mock_http):
mock_http.register_uri(
'POST',
'https://twilix.exotel.in/v1/Accounts/123/Sms/send.json',
text=''.join((
'<?xml version="1.0" encoding="UTF-8"?>',
'<TwilioResponse>',
'<SMSMessage>...</SMSMessage>',
'</TwilioResponse>',
)),
)
e = Exotel(sid='123', token='abc')
rep = e.sms(
from_number='012-345-6789',
to='345-678-9012',
body='Hello, world!',
)
assert rep.status_code == 200
def test_call_flow(mock_http):
mock_http.register_uri(
'POST',
'https://twilix.exotel.in/v1/Accounts/123/Calls/connect.json',
text=''.join((
'<?xml version="1.0" encoding="UTF-8"?>',
'<TwilioResponse>',
'<Call>...</Call>',
'</TwilioResponse>',
)),
)
e = Exotel(sid='123', token='abc')
rep = e.call_flow(
from_number='012-345-6789',
caller_id='345-678-9012',
flow_id='345',
)
assert rep.status_code == 200
def test_call_number(mock_http):
mock_http.register_uri(
'POST',
'https://twilix.exotel.in/v1/Accounts/123/Calls/connect.json',
text=''.join((
'<?xml version="1.0" encoding="UTF-8"?>',
'<TwilioResponse>',
'<Call>...</Call>',
'</TwilioResponse>',
)),
)
e = Exotel(sid='123', token='abc')
rep = e.call_number(
from_number='012-345-6789',
to='345-678-9012',
caller_id='678-901-2345',
)
assert rep.status_code == 200
def test_call_details(mock_http):
mock_http.register_uri(
'GET',
'https://twilix.exotel.in/v1/Accounts/123/Calls/234.json',
text=''.join((
'<?xml version="1.0" encoding="UTF-8"?>',
'<TwilioResponse>',
'<Call>...</Call>',
'</TwilioResponse>',
)),
)
e = Exotel(sid='123', token='abc')
rep = e.call_details(call_sid='234')
assert rep.status_code == 200
def test_sms_details(mock_http):
mock_http.register_uri(
'GET',
'https://twilix.exotel.in/v1/Accounts/123/Sms/Messages/234.json',
text=''.join((
'<?xml version="1.0" encoding="UTF-8"?>',
'<TwilioResponse>',
'<Call>...</Call>',
'</TwilioResponse>',
)),
)
e = Exotel(sid='123', token='abc')
rep = e.sms_details(sms_sid='234')
assert rep.status_code == 200
|