add log warning in dev environment if phone number is opted out (notify-api-539)

This commit is contained in:
Kenneth Kehl
2024-02-13 09:39:53 -08:00
parent 2f5fea6d81
commit 467a2919f4
2 changed files with 45 additions and 7 deletions

View File

@@ -1,6 +1,7 @@
# import pytest
from datetime import datetime
import pytest
from flask import current_app
from app import aws_cloudwatch_client
@@ -54,6 +55,27 @@ def side_effect(filterPattern, logGroupName, startTime, endTime):
return {"events": []}
@pytest.mark.parametrize(
"response, notify_id, expected_message",
[
(
"Phone has blocked SMS",
"abc",
"\x1b[31mThe phone number for notification_id abc is OPTED OUT. You need to opt back in\x1b[0m",
),
(
"Some phone is opted out",
"xyz",
"\x1b[31mThe phone number for notification_id xyz is OPTED OUT. You need to opt back in\x1b[0m",
),
("Phone is A-OK", "123", None),
],
)
def test_warn_if_dev_is_opted_out(response, notify_id, expected_message):
result = aws_cloudwatch_client.warn_if_dev_is_opted_out(response, notify_id)
assert result == expected_message
def test_check_sms_success(notify_api, mocker):
aws_cloudwatch_client.init_app(current_app)
boto_mock = mocker.patch.object(aws_cloudwatch_client, "_client", create=True)