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

Landline validation dissallow premium #4143

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
35 changes: 35 additions & 0 deletions tests/app/notifications/test_process_notification.py
Original file line number Diff line number Diff line change
Expand Up @@ -452,6 +452,41 @@ def test_persist_notification_without_send_to_landline_raises_invalidphoneerror(
)


@pytest.mark.parametrize(
"recipient",
[
"0845 46 46", # short premium
"0900 123 4567", # premium
],
)
def test_persist_notification_with_send_to_landline_to_premium_number_raises_invallidphoneerror(
sample_job,
sample_api_key,
mocker,
recipient,
):
sample_job.service.permissions = [
# and any other permissions we need
ServicePermission(service_id=sample_job.service.id, permission=SMS_TYPE),
ServicePermission(service_id=sample_job.service.id, permission=SMS_TO_UK_LANDLINES),
]
with pytest.raises(InvalidPhoneError) as exc:
persist_notification(
template_id=sample_job.template.id,
template_version=sample_job.template.version,
recipient=recipient,
service=sample_job.service,
personalisation=None,
notification_type="sms",
api_key_id=sample_api_key.id,
key_type=sample_api_key.key_type,
job_id=sample_job.id,
job_row_number=10,
client_reference="ref from client",
)
assert exc.value.code == InvalidPhoneError.Codes.INVALID_NUMBER


def test_persist_notification_with_international_info_does_not_store_for_email(sample_job, sample_api_key, mocker):

persist_notification(
Expand Down
You are viewing a condensed version of this merge commit. You can view the full changes here.