mirror of
https://github.com/caronc/apprise.git
synced 2025-08-10 08:47:53 +02:00
Twilio WhatsApp support added (#1173)
This commit is contained in:
@ -69,8 +69,8 @@ apprise_url_tests = (
|
||||
# sid and token provided and from but invalid from no
|
||||
'instance': TypeError,
|
||||
}),
|
||||
('twilio://AC{}:{}@{}/123/{}/abcd/'.format(
|
||||
'a' * 32, 'b' * 32, '3' * 11, '9' * 15), {
|
||||
('twilio://AC{}:{}@{}/123/{}/abcd/w:{}'.format(
|
||||
'a' * 32, 'b' * 32, '3' * 11, '9' * 15, 8 * 11), {
|
||||
# valid everything but target numbers
|
||||
'instance': NotifyTwilio,
|
||||
}),
|
||||
@ -81,6 +81,20 @@ apprise_url_tests = (
|
||||
# Our expected url(privacy=True) startswith() response:
|
||||
'privacy_url': 'twilio://...aaaa:b...b@12345',
|
||||
}),
|
||||
('twilio://AC{}:{}@98765/{}/w:{}/'.format(
|
||||
'a' * 32, 'b' * 32, '4' * 11, '5' * 11), {
|
||||
# using short-code (5 characters) and 1 twillio address ignored
|
||||
# because source phone number can not be a short code
|
||||
'instance': NotifyTwilio,
|
||||
|
||||
# Our expected url(privacy=True) startswith() response:
|
||||
'privacy_url': 'twilio://...aaaa:b...b@98765',
|
||||
}),
|
||||
('twilio://AC{}:{}@w:12345/{}/{}'.format(
|
||||
'a' * 32, 'b' * 32, '4' * 11, '5' * 11), {
|
||||
# Invalid short-code
|
||||
'instance': TypeError,
|
||||
}),
|
||||
('twilio://AC{}:{}@123456/{}'.format('a' * 32, 'b' * 32, '4' * 11), {
|
||||
# using short-code (6 characters)
|
||||
'instance': NotifyTwilio,
|
||||
@ -95,6 +109,11 @@ apprise_url_tests = (
|
||||
# use get args to acomplish the same thing
|
||||
'instance': NotifyTwilio,
|
||||
}),
|
||||
('twilio://_?sid=AC{}&token={}&from={}&to=w:{}'.format(
|
||||
'a' * 32, 'b' * 32, '5' * 11, '6' * 11), {
|
||||
# Support whatsapp (w: before number)
|
||||
'instance': NotifyTwilio,
|
||||
}),
|
||||
('twilio://_?sid=AC{}&token={}&source={}'.format(
|
||||
'a' * 32, 'b' * 32, '5' * 11), {
|
||||
# use get args to acomplish the same thing (use source instead of from)
|
||||
@ -228,6 +247,11 @@ def test_plugin_twilio_edge_cases(mock_post):
|
||||
NotifyTwilio(
|
||||
account_sid=account_sid, auth_token=None, source=source)
|
||||
|
||||
# Source is bad
|
||||
with pytest.raises(TypeError):
|
||||
NotifyTwilio(
|
||||
account_sid=account_sid, auth_token=auth_token, source='')
|
||||
|
||||
# a error response
|
||||
response.status_code = 400
|
||||
response.content = dumps({
|
||||
|
Reference in New Issue
Block a user