Add simulated numbers to allow list in trial mode

This commit is contained in:
Andrew Shumway
2024-03-13 16:20:39 -06:00
parent 8a6cc76d15
commit 01df741609
2 changed files with 23 additions and 0 deletions

View File

@@ -1,5 +1,6 @@
import itertools
from flask import current_app
from notifications_utils.recipients import allowed_to_send_to
from app.dao.services_dao import dao_fetch_service_by_id
@@ -45,6 +46,9 @@ def service_allowed_to_send_to(
member.recipient for member in service.guest_list if allow_guest_list_recipients
]
# As per discussion we have decided to allow official simulated
# numbers to go out in trial mode for development purposes.
guest_list_members.extend(current_app.config["SIMULATED_SMS_NUMBERS"])
if (key_type == KeyType.NORMAL and service.restricted) or (
key_type == KeyType.TEAM
):

View File

@@ -34,6 +34,7 @@ from app.serialised_models import (
SerialisedService,
SerialisedTemplate,
)
from app.service.utils import service_allowed_to_send_to
from app.utils import get_template_instance
from app.v2.errors import BadRequestError, RateLimitError, TotalRequestsError
from tests.app.db import (
@@ -802,3 +803,21 @@ def test_check_service_over_total_message_limit(mocker, sample_service):
sample_service,
)
assert service_stats == 0
def test_service_allowed_to_send_to_simulated_numbers():
trial_mode_service = create_service(service_name="trial mode", restricted=True)
can_send = service_allowed_to_send_to(
"+14254147755",
trial_mode_service,
KeyType.NORMAL,
allow_guest_list_recipients=True,
)
can_not_send = service_allowed_to_send_to(
"+15555555555",
trial_mode_service,
KeyType.NORMAL,
allow_guest_list_recipients=True,
)
assert can_send is True
assert can_not_send is False