-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
215 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
""" | ||
Revision ID: 0450_enable_pinpoint_provider | ||
Revises: 0449_update_magic_link_auth | ||
Create Date: 2021-01-08 09:03:00 .214680 | ||
""" | ||
from alembic import op | ||
|
||
revision = "0450_enable_pinpoint_provider" | ||
down_revision = "0449_update_magic_link_auth" | ||
|
||
|
||
def upgrade(): | ||
op.execute("UPDATE provider_details set active=true where identifier in ('pinpoint');") | ||
|
||
|
||
def downgrade(): | ||
op.execute("UPDATE provider_details set active=false where identifier in ('pinpoint');") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
import pytest | ||
|
||
from app import aws_pinpoint_client | ||
from tests.conftest import set_config_values | ||
|
||
|
||
@pytest.mark.serial | ||
def test_send_sms_sends_to_default_pool(notify_api, mocker, sample_template): | ||
boto_mock = mocker.patch.object(aws_pinpoint_client, "_client", create=True) | ||
mocker.patch.object(aws_pinpoint_client, "statsd_client", create=True) | ||
to = "6135555555" | ||
content = "foo" | ||
reference = "ref" | ||
|
||
with set_config_values( | ||
notify_api, | ||
{ | ||
"AWS_PINPOINT_SC_POOL_ID": "sc_pool_id", | ||
"AWS_PINPOINT_DEFAULT_POOL_ID": "default_pool_id", | ||
"AWS_PINPOINT_CONFIGURATION_SET_NAME": "config_set_name", | ||
"AWS_PINPOINT_SC_TEMPLATE_IDS": [], | ||
}, | ||
): | ||
aws_pinpoint_client.send_sms(to, content, reference=reference, template_id=sample_template.id) | ||
|
||
boto_mock.send_text_message.assert_called_once_with( | ||
DestinationPhoneNumber="+16135555555", | ||
OriginationIdentity="default_pool_id", | ||
MessageBody=content, | ||
MessageType="TRANSACTIONAL", | ||
ConfigurationSetName="config_set_name", | ||
) | ||
|
||
|
||
@pytest.mark.serial | ||
def test_send_sms_sends_to_shortcode_pool(notify_api, mocker, sample_template): | ||
boto_mock = mocker.patch.object(aws_pinpoint_client, "_client", create=True) | ||
mocker.patch.object(aws_pinpoint_client, "statsd_client", create=True) | ||
to = "6135555555" | ||
content = "foo" | ||
reference = "ref" | ||
|
||
with set_config_values( | ||
notify_api, | ||
{ | ||
"AWS_PINPOINT_SC_POOL_ID": "sc_pool_id", | ||
"AWS_PINPOINT_DEFAULT_POOL_ID": "default_pool_id", | ||
"AWS_PINPOINT_CONFIGURATION_SET_NAME": "config_set_name", | ||
"AWS_PINPOINT_SC_TEMPLATE_IDS": [str(sample_template.id)], | ||
}, | ||
): | ||
aws_pinpoint_client.send_sms(to, content, reference=reference, template_id=sample_template.id) | ||
|
||
boto_mock.send_text_message.assert_called_once_with( | ||
DestinationPhoneNumber="+16135555555", | ||
OriginationIdentity="sc_pool_id", | ||
MessageBody=content, | ||
MessageType="TRANSACTIONAL", | ||
ConfigurationSetName="config_set_name", | ||
) | ||
|
||
|
||
def test_send_sms_returns_raises_error_if_there_is_no_valid_number_is_found(notify_api, mocker): | ||
mocker.patch.object(aws_pinpoint_client, "_client", create=True) | ||
mocker.patch.object(aws_pinpoint_client, "statsd_client", create=True) | ||
|
||
to = "" | ||
content = reference = "foo" | ||
|
||
with pytest.raises(ValueError) as excinfo: | ||
aws_pinpoint_client.send_sms(to, content, reference) | ||
|
||
assert "No valid numbers found for SMS delivery" in str(excinfo.value) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.