Twilio WhatsApp support added (#1173)

This commit is contained in:
Chris Caron
2024-07-22 18:23:39 -04:00
committed by GitHub
parent 7efb6c5132
commit 1e4b4355ce
4 changed files with 111 additions and 23 deletions

View File

@ -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({