Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Production deploy 2/8/24 #795

Merged
merged 10 commits into from
Feb 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion app/aws/s3.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,10 @@ def extract_phones(job):
current_app.logger.info(f"LENGTH OF ROW IS {len(row)}")
if phone_index >= len(row):
phones[job_row] = "Error: can't retrieve phone number"
current_app.logger.error("Corrupt csv file")
current_app.logger.error(
"Corrupt csv file, missing columns or possibly a byte order mark in the file"
)

else:
my_phone = row[phone_index]
my_phone = re.sub(r"[\+\s\(\)\-\.]*", "", my_phone)
Expand Down
3 changes: 2 additions & 1 deletion app/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,8 @@ class Config(object):
"simulate-delivered-2@notifications.service.gov.uk",
"simulate-delivered-3@notifications.service.gov.uk",
)
SIMULATED_SMS_NUMBERS = ("+12028675000", "+12028675111", "+12028675222")
# 7755 is success, 7167 is failure
SIMULATED_SMS_NUMBERS = ("+14254147755", "+14254147167")

FREE_SMS_TIER_FRAGMENT_COUNT = 250000

Expand Down
5 changes: 4 additions & 1 deletion app/dao/notifications_dao.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ def _update_notification_status(
current_status=notification.status, status=status
)
notification.status = status
notification.sent_at = datetime.utcnow()
if provider_response:
notification.provider_response = provider_response
if carrier:
Expand Down Expand Up @@ -318,13 +319,15 @@ def _filter_query(query, filter_dict=None):
def sanitize_successful_notification_by_id(notification_id, carrier, provider_response):
update_query = """
update notifications set provider_response=:response, carrier=:carrier,
notification_status='delivered', "to"='1', normalised_to='1'
notification_status='delivered', sent_at=:sent_at, "to"='1', normalised_to='1'
where id=:notification_id
"""

input_params = {
"notification_id": notification_id,
"carrier": carrier,
"response": provider_response,
"sent_at": datetime.utcnow(),
}

db.session.execute(update_query, input_params)
Expand Down
88 changes: 41 additions & 47 deletions poetry.lock

Large diffs are not rendered by default.

9 changes: 3 additions & 6 deletions tests/app/notifications/test_process_notification.py
Original file line number Diff line number Diff line change
Expand Up @@ -254,11 +254,8 @@ def test_send_notification_to_queue_throws_exception_deletes_notification(
@pytest.mark.parametrize(
"to_address, notification_type, expected",
[
("+12028675000", "sms", True),
("+12028675111", "sms", True),
("+12028675222", "sms", True),
("2028675000", "sms", True),
("2028675111", "sms", True),
("+14254147755", "sms", True),
("+14254147167", "sms", True),
("simulate-delivered@notifications.service.gov.uk", "email", True),
("simulate-delivered-2@notifications.service.gov.uk", "email", True),
("simulate-delivered-3@notifications.service.gov.uk", "email", True),
Expand All @@ -275,7 +272,7 @@ def test_simulated_recipient(notify_api, to_address, notification_type, expected
'simulate-delivered-2@notifications.service.gov.uk',
'simulate-delivered-2@notifications.service.gov.uk'
)
SIMULATED_SMS_NUMBERS = ('+12028675000', '+12028675111', '+12028675222')
SIMULATED_SMS_NUMBERS = ("+14254147755", "+14254147167")
"""
formatted_address = None

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -881,7 +881,7 @@ def test_should_not_persist_notification_or_send_email_if_simulated_email(
assert Notification.query.count() == 0


@pytest.mark.parametrize("to_sms", ["2028675000", "2028675111", "+12028675222"])
@pytest.mark.parametrize("to_sms", ["+14254147755", "+14254147167"])
def test_should_not_persist_notification_or_send_sms_if_simulated_number(
client, to_sms, sample_template, mocker
):
Expand Down
5 changes: 2 additions & 3 deletions tests/app/v2/notifications/test_post_notifications.py
Original file line number Diff line number Diff line change
Expand Up @@ -532,9 +532,8 @@ def test_post_email_notification_returns_201(
("simulate-delivered@notifications.service.gov.uk", EMAIL_TYPE),
("simulate-delivered-2@notifications.service.gov.uk", EMAIL_TYPE),
("simulate-delivered-3@notifications.service.gov.uk", EMAIL_TYPE),
("2028675000", "sms"),
("2028675111", "sms"),
("2028675222", "sms"),
("+14254147167", "sms"),
("+14254147755", "sms"),
],
)
def test_should_not_persist_or_send_notification_if_simulated_recipient(
Expand Down
Loading