diff --git a/app/config.py b/app/config.py index da8b718790..287540dd09 100644 --- a/app/config.py +++ b/app/config.py @@ -517,10 +517,6 @@ class Config(object): BR_WARNING_PERCENTAGE = 0.05 BR_CRITICAL_PERCENTAGE = 0.1 - # add and use sms_daily_limit - FF_SPIKE_SMS_DAILY_LIMIT = env.bool("FF_SPIKE_SMS_DAILY_LIMIT", False) - FF_SMS_PARTS_UI = env.bool("FF_SMS_PARTS_UI", False) - FF_SALESFORCE_CONTACT = env.bool("FF_SALESFORCE_CONTACT", False) # Feature flags for bounce rate diff --git a/app/dao/fact_notification_status_dao.py b/app/dao/fact_notification_status_dao.py index 6228db4664..169063ebf8 100644 --- a/app/dao/fact_notification_status_dao.py +++ b/app/dao/fact_notification_status_dao.py @@ -244,18 +244,7 @@ def fetch_notification_status_for_service_for_today_and_7_previous_days(service_ FactNotificationStatus.notification_type.label("notification_type"), FactNotificationStatus.notification_status.label("status"), *([FactNotificationStatus.template_id.label("template_id")] if by_template else []), - *( - [ - case( - [ - (FactNotificationStatus.notification_type == "email", FactNotificationStatus.notification_count), - ], - else_=FactNotificationStatus.billable_units, - ).label("count") - ] - if current_app.config["FF_SMS_PARTS_UI"] - else [FactNotificationStatus.notification_count.label("count")] - ), + *([FactNotificationStatus.notification_count.label("count")]), ).filter( FactNotificationStatus.service_id == service_id, FactNotificationStatus.bst_date >= start_date, @@ -267,18 +256,7 @@ def fetch_notification_status_for_service_for_today_and_7_previous_days(service_ Notification.notification_type.cast(db.Text), Notification.status, *([Notification.template_id] if by_template else []), - *( - [ - case( - [ - (Notification.notification_type == "email", func.count()), - ], - else_=func.sum(Notification.billable_units), - ).label("count") - ] - if current_app.config["FF_SMS_PARTS_UI"] - else [func.count().label("count")] - ), + *([func.count().label("count")]), ) .filter( Notification.created_at >= midnight_n_days_ago(limit_days), diff --git a/app/dao/services_dao.py b/app/dao/services_dao.py index a7f33f2917..29b95e8f8b 100644 --- a/app/dao/services_dao.py +++ b/app/dao/services_dao.py @@ -471,18 +471,7 @@ def _stats_for_service_query(service_id): db.session.query( Notification.notification_type, Notification.status, - *( - [ - case( - [ - (Notification.notification_type == "email", func.count(Notification.id)), - ], - else_=func.sum(Notification.billable_units), - ).label("count") - ] - if current_app.config["FF_SMS_PARTS_UI"] - else [func.count(Notification.id).label("count")] - ), + *([func.count(Notification.id).label("count")]), ) .filter( Notification.service_id == service_id, diff --git a/app/notifications/validators.py b/app/notifications/validators.py index c065919390..d7678fb868 100644 --- a/app/notifications/validators.py +++ b/app/notifications/validators.py @@ -214,8 +214,6 @@ def time_until_end_of_day() -> timedelta: def check_sms_limit_increment_redis_send_warnings_if_needed(service: Service, requested_sms=0) -> None: - if not current_app.config["FF_SPIKE_SMS_DAILY_LIMIT"]: - return if not current_app.config["REDIS_ENABLED"]: return @@ -295,9 +293,7 @@ def warn_about_daily_message_limit(service: Service, messages_sent): def send_near_sms_limit_email(service: Service): send_notification_to_service_users( service_id=service.id, - template_id=current_app.config["NEAR_DAILY_SMS_LIMIT_TEMPLATE_ID"] - if current_app.config["FF_SPIKE_SMS_DAILY_LIMIT"] - else current_app.config["NEAR_DAILY_LIMIT_TEMPLATE_ID"], + template_id=current_app.config["NEAR_DAILY_SMS_LIMIT_TEMPLATE_ID"], personalisation={ "service_name": service.name, "contact_url": f"{current_app.config['ADMIN_BASE_URL']}/contact", @@ -331,9 +327,7 @@ def send_near_email_limit_email(service: Service) -> None: def send_sms_limit_reached_email(service: Service): send_notification_to_service_users( service_id=service.id, - template_id=current_app.config["REACHED_DAILY_SMS_LIMIT_TEMPLATE_ID"] - if current_app.config["FF_SPIKE_SMS_DAILY_LIMIT"] - else current_app.config["REACHED_DAILY_LIMIT_TEMPLATE_ID"], + template_id=current_app.config["REACHED_DAILY_SMS_LIMIT_TEMPLATE_ID"], personalisation={ "service_name": service.name, "contact_url": f"{current_app.config['ADMIN_BASE_URL']}/contact", diff --git a/app/service/rest.py b/app/service/rest.py index 377ac2adb9..4f9db19a28 100644 --- a/app/service/rest.py +++ b/app/service/rest.py @@ -299,7 +299,7 @@ def update_service(service_id): if sms_limit_changed: redis_store.delete(near_sms_daily_limit_cache_key(service_id)) redis_store.delete(over_sms_daily_limit_cache_key(service_id)) - if not fetched_service.restricted and current_app.config["FF_SPIKE_SMS_DAILY_LIMIT"]: + if not fetched_service.restricted: _warn_service_users_about_sms_limit_changed(service_id, current_data) if service_going_live: diff --git a/app/v2/notifications/post_notifications.py b/app/v2/notifications/post_notifications.py index ca35ed8689..e9cf3dde10 100644 --- a/app/v2/notifications/post_notifications.py +++ b/app/v2/notifications/post_notifications.py @@ -160,7 +160,6 @@ def post_bulk(): raise BadRequestError(message=f"Error decoding arguments: {e.description}", status_code=400) max_rows = current_app.config["CSV_MAX_ROWS"] - check_sms_limit = current_app.config["FF_SPIKE_SMS_DAILY_LIMIT"] epoch_seeding_bounce = current_app.config["FF_BOUNCE_RATE_SEED_EPOCH_MS"] bounce_rate_v1 = current_app.config["FF_BOUNCE_RATE_BACKEND"] if bounce_rate_v1 and epoch_seeding_bounce: @@ -173,7 +172,7 @@ def post_bulk(): template = validate_template_exists(form["template_id"], authenticated_service) check_service_has_permission(template.template_type, authenticated_service.permissions) - if template.template_type == SMS_TYPE and check_sms_limit: + if template.template_type == SMS_TYPE: fragments_sent = fetch_todays_requested_sms_count(authenticated_service.id) remaining_messages = authenticated_service.sms_daily_limit - fragments_sent else: @@ -690,13 +689,8 @@ def row_error(row): message=f"Some rows have errors. {errors}.", status_code=400, ) - # TODO: - # - right now there are no other errors in RecipientCSV so this else is not needed - # - if FF_SPIKE_SMS_DAILY_LIMIT is false we do not want to throw this error if only more_sms_rows_than_can_send is set - # - after the FF is turned on / removed, we will restore this else - # - # else: - # raise NotImplementedError("Got errors but code did not handle") + else: + raise NotImplementedError("Got errors but code did not handle") def create_bulk_job(service, api_key, template, form, recipient_csv): diff --git a/tests/app/dao/test_fact_notification_status_dao.py b/tests/app/dao/test_fact_notification_status_dao.py index 7cf01ed5c1..13abbcd6be 100644 --- a/tests/app/dao/test_fact_notification_status_dao.py +++ b/tests/app/dao/test_fact_notification_status_dao.py @@ -51,7 +51,6 @@ create_template, save_notification, ) -from tests.conftest import set_config def test_update_fact_notification_status(notify_db_session): @@ -268,7 +267,6 @@ def test_fetch_notification_status_for_service_for_today_and_7_previous_days( status="delivered", ) ) - results = sorted( fetch_notification_status_for_service_for_today_and_7_previous_days(service_1.id), key=lambda x: (x.notification_type, x.status), @@ -324,34 +322,18 @@ def test_fetch_notification_status_by_template_for_service_for_today_and_7_previ status="delivered", ) ) - - with set_config(notify_api, "FF_SMS_PARTS_UI", False): - results = fetch_notification_status_for_service_for_today_and_7_previous_days(service_1.id, by_template=True) - assert [ - ("email Template Name", False, mock.ANY, "email", "delivered", 1), - ("email Template Name", False, mock.ANY, "email", "delivered", 3), - ("letter Template Name", False, mock.ANY, "letter", "delivered", 5), - ("sms Template 1", False, mock.ANY, "sms", "created", 1), - ("sms Template Name", False, mock.ANY, "sms", "created", 1), - ("sms Template 1", False, mock.ANY, "sms", "delivered", 1), - ("sms Template 2", False, mock.ANY, "sms", "delivered", 1), - ("sms Template Name", False, mock.ANY, "sms", "delivered", 10), - ("sms Template Name", False, mock.ANY, "sms", "delivered", 11), - ] == sorted(results, key=lambda x: (x.notification_type, x.status, x.template_name, x.count)) - - with set_config(notify_api, "FF_SMS_PARTS_UI", True): - results = fetch_notification_status_for_service_for_today_and_7_previous_days(service_1.id, by_template=True) - assert [ - ("email Template Name", False, mock.ANY, "email", "delivered", 1), - ("email Template Name", False, mock.ANY, "email", "delivered", 3), - ("letter Template Name", False, mock.ANY, "letter", "delivered", 5), - ("sms Template 1", False, mock.ANY, "sms", "created", 1), - ("sms Template Name", False, mock.ANY, "sms", "created", 1), - ("sms Template 1", False, mock.ANY, "sms", "delivered", 1), - ("sms Template 2", False, mock.ANY, "sms", "delivered", 1), - ("sms Template Name", False, mock.ANY, "sms", "delivered", 11), - ("sms Template Name", False, mock.ANY, "sms", "delivered", 20), - ] == sorted(results, key=lambda x: (x.notification_type, x.status, x.template_name, x.count)) + results = fetch_notification_status_for_service_for_today_and_7_previous_days(service_1.id, by_template=True) + assert [ + ("email Template Name", False, mock.ANY, "email", "delivered", 1), + ("email Template Name", False, mock.ANY, "email", "delivered", 3), + ("letter Template Name", False, mock.ANY, "letter", "delivered", 5), + ("sms Template 1", False, mock.ANY, "sms", "created", 1), + ("sms Template Name", False, mock.ANY, "sms", "created", 1), + ("sms Template 1", False, mock.ANY, "sms", "delivered", 1), + ("sms Template 2", False, mock.ANY, "sms", "delivered", 1), + ("sms Template Name", False, mock.ANY, "sms", "delivered", 10), + ("sms Template Name", False, mock.ANY, "sms", "delivered", 11), + ] == sorted(results, key=lambda x: (x.notification_type, x.status, x.template_name, x.count)) def test_get_total_notifications_sent_for_api_key(notify_db_session): diff --git a/tests/app/dao/test_services_dao.py b/tests/app/dao/test_services_dao.py index bcbc985783..ecdb17f634 100644 --- a/tests/app/dao/test_services_dao.py +++ b/tests/app/dao/test_services_dao.py @@ -87,7 +87,6 @@ create_user, save_notification, ) -from tests.conftest import set_config # from unittest import mock @@ -966,39 +965,21 @@ def test_fetch_stats_counts_correctly(notify_db_session, notify_api): save_notification(create_notification(template=email_template, status="technical-failure")) save_notification(create_notification(template=sms_template, status="created", billable_units=10)) - with set_config(notify_api, "FF_SMS_PARTS_UI", False): - stats = dao_fetch_stats_for_service(sms_template.service_id, 7) - stats = sorted(stats, key=lambda x: (x.notification_type, x.status)) - assert len(stats) == 3 + stats = dao_fetch_stats_for_service(sms_template.service_id, 7) + stats = sorted(stats, key=lambda x: (x.notification_type, x.status)) + assert len(stats) == 3 - assert stats[0].notification_type == "email" - assert stats[0].status == "created" - assert stats[0].count == 2 - - assert stats[1].notification_type == "email" - assert stats[1].status == "technical-failure" - assert stats[1].count == 1 - - assert stats[2].notification_type == "sms" - assert stats[2].status == "created" - assert stats[2].count == 1 - - with set_config(notify_api, "FF_SMS_PARTS_UI", True): - stats = dao_fetch_stats_for_service(sms_template.service_id, 7) - stats = sorted(stats, key=lambda x: (x.notification_type, x.status)) - assert len(stats) == 3 - - assert stats[0].notification_type == "email" - assert stats[0].status == "created" - assert stats[0].count == 2 + assert stats[0].notification_type == "email" + assert stats[0].status == "created" + assert stats[0].count == 2 - assert stats[1].notification_type == "email" - assert stats[1].status == "technical-failure" - assert stats[1].count == 1 + assert stats[1].notification_type == "email" + assert stats[1].status == "technical-failure" + assert stats[1].count == 1 - assert stats[2].notification_type == "sms" - assert stats[2].status == "created" - assert stats[2].count == 10 + assert stats[2].notification_type == "sms" + assert stats[2].status == "created" + assert stats[2].count == 1 def test_fetch_stats_counts_should_ignore_team_key(notify_db_session): diff --git a/tests/app/notifications/test_validators.py b/tests/app/notifications/test_validators.py index ab14ea786d..2c1099f6b9 100644 --- a/tests/app/notifications/test_validators.py +++ b/tests/app/notifications/test_validators.py @@ -101,8 +101,7 @@ def test_check_service_message_limit_in_cache_with_unrestricted_service_is_allow mocker.patch("app.notifications.validators.redis_store.set") mocker.patch("app.notifications.validators.services_dao") if limit_type == "sms": - with set_config(notify_api, "FF_SPIKE_SMS_DAILY_LIMIT", True): - check_sms_daily_limit(sample_service) + check_sms_daily_limit(sample_service) else: check_email_daily_limit(sample_service) app.notifications.validators.redis_store.set.assert_not_called() @@ -119,8 +118,7 @@ def test_check_service_message_limit_in_cache_under_message_limit_passes( mocker.patch("app.notifications.validators.redis_store.set") mocker.patch("app.notifications.validators.services_dao") if limit_type == "sms": - with set_config(notify_api, "FF_SPIKE_SMS_DAILY_LIMIT", True): - check_sms_daily_limit(sample_service) + check_sms_daily_limit(sample_service) else: check_email_daily_limit(sample_service) app.notifications.validators.redis_store.set.assert_not_called() @@ -152,8 +150,7 @@ def test_should_not_access_database_if_redis_disabled(self, notify_api, sample_s with set_config(notify_api, "REDIS_ENABLED", False): db_mock = mocker.patch("app.notifications.validators.services_dao") check_service_over_daily_message_limit("normal", sample_service) - with set_config(notify_api, "FF_SPIKE_SMS_DAILY_LIMIT", True): - check_sms_daily_limit(sample_service) + check_sms_daily_limit(sample_service) assert db_mock.method_calls == [] @@ -218,8 +215,7 @@ def test_check_service_message_limit_records_nearing_daily_limit( create_sample_notification(notify_db, notify_db_session, service=service, template=template) if limit_type == "sms": - with set_config(notify_api, "FF_SPIKE_SMS_DAILY_LIMIT", True): - check_sms_limit_increment_redis_send_warnings_if_needed(service) + check_sms_limit_increment_redis_send_warnings_if_needed(service) else: with set_config(notify_api, "FF_EMAIL_DAILY_LIMIT", True): check_email_limit_increment_redis_send_warnings_if_needed(service) @@ -283,8 +279,7 @@ def test_check_service_message_limit_in_cache_over_message_limit_fails( assert e.value.fields == [] with pytest.raises(TooManySMSRequestsError) as e: - with set_config(notify_api, "FF_SPIKE_SMS_DAILY_LIMIT", True): - check_sms_daily_limit(service) + check_sms_daily_limit(service) assert e.value.status_code == 429 assert e.value.message == "Exceeded SMS daily sending limit of 4 fragments" assert e.value.fields == [] @@ -337,8 +332,7 @@ def test_check_service_message_limit_skip_statsd_over_message_no_limit_fails_sms # When service = create_sample_service(notify_db, notify_db_session, restricted=True, limit=4, sms_limit=4) check_service_over_daily_message_limit("normal", service) - with set_config(notify_api, "FF_SPIKE_SMS_DAILY_LIMIT", True): - check_sms_daily_limit(service) + check_sms_daily_limit(service) # Then app_statsd.statsd_client.incr.assert_not_called() diff --git a/tests/app/v2/notifications/test_post_notifications.py b/tests/app/v2/notifications/test_post_notifications.py index 412cfe5c8c..e86c405f64 100644 --- a/tests/app/v2/notifications/test_post_notifications.py +++ b/tests/app/v2/notifications/test_post_notifications.py @@ -1463,7 +1463,7 @@ def test_post_sms_enough_fragments_left(self, notify_api, client, notify_db, not create_sample_notification(notify_db, notify_db_session, service=service) auth_header = create_authorization_header(service_id=template.service_id) - with set_config_values(notify_api, {"FF_SPIKE_SMS_DAILY_LIMIT": True, "REDIS_ENABLED": True}): + with set_config_values(notify_api, {"REDIS_ENABLED": True}): response = client.post( path="/v2/notifications/sms", data=json.dumps(data), @@ -1484,7 +1484,7 @@ def test_post_sms_not_enough_fragments_left(self, notify_api, client, notify_db, create_sample_notification(notify_db, notify_db_session, service=service) auth_header = create_authorization_header(service_id=template.service_id) - with set_config_values(notify_api, {"FF_SPIKE_SMS_DAILY_LIMIT": True, "REDIS_ENABLED": True}): + with set_config_values(notify_api, {"REDIS_ENABLED": True}): response = client.post( path="/v2/notifications/sms", data=json.dumps(data), @@ -1492,29 +1492,6 @@ def test_post_sms_not_enough_fragments_left(self, notify_api, client, notify_db, ) assert response.status_code == 429 - def test_post_sms_not_enough_fragments_left_FF_SPIKE_SMS_DAILY_LIMIT_false( - self, notify_api, client, notify_db, notify_db_session, mocker - ): - mocker.patch("app.sms_normal_publish.publish") - service = create_service(sms_daily_limit=10, message_limit=100) - template = create_sample_template(notify_db, notify_db_session, content=500 * "a", service=service, template_type="sms") - data = { - "phone_number": "+16502532222", - "template_id": str(template.id), - "personalisation": {" Name": "Jo"}, - } - for x in range(7): - create_sample_notification(notify_db, notify_db_session, service=service) - auth_header = create_authorization_header(service_id=template.service_id) - - with set_config_values(notify_api, {"FF_SPIKE_SMS_DAILY_LIMIT": False, "REDIS_ENABLED": True}): - response = client.post( - path="/v2/notifications/sms", - data=json.dumps(data), - headers=[("Content-Type", "application/json"), auth_header], - ) - assert response.status_code == 201 - class TestSMSFragmentCounter: # Testing API one-off: @@ -1539,7 +1516,7 @@ def __send_sms(): ) save_model_api_key(api_key) - with set_config_values(notify_api, {"FF_SPIKE_SMS_DAILY_LIMIT": True, "REDIS_ENABLED": True}): + with set_config_values(notify_api, {"REDIS_ENABLED": True}): response = client.post( path="/v2/notifications/sms", data=json.dumps(data), @@ -1587,7 +1564,7 @@ def __send_sms(): ) save_model_api_key(api_key) - with set_config_values(notify_api, {"FF_SPIKE_SMS_DAILY_LIMIT": True, "REDIS_ENABLED": True}): + with set_config_values(notify_api, {"REDIS_ENABLED": True}): response = client.post( path="/v2/notifications/bulk", data=json.dumps(data), @@ -1631,7 +1608,7 @@ def __send_sms(): ) save_model_api_key(api_key) - with set_config_values(notify_api, {"FF_SPIKE_SMS_DAILY_LIMIT": True, "REDIS_ENABLED": True}): + with set_config_values(notify_api, {"REDIS_ENABLED": True}): response = client.post( path="/v2/notifications/bulk", data=json.dumps(data), @@ -1672,7 +1649,7 @@ def test_ADMIN_ONEOFF_post_sms_with_test_phone_number_does_not_count_towards_lim increment_todays_requested_sms_count = mocker.patch("app.notifications.validators.increment_todays_requested_sms_count") def __send_sms(): - with set_config_values(notify_api, {"FF_SPIKE_SMS_DAILY_LIMIT": True, "REDIS_ENABLED": True}): + with set_config_values(notify_api, {"REDIS_ENABLED": True}): token = create_jwt_token( current_app.config["ADMIN_CLIENT_SECRET"], client_id=current_app.config["ADMIN_CLIENT_USER_NAME"] ) @@ -1721,7 +1698,7 @@ def test_ADMIN_CSV_post_sms_with_test_phone_number_does_not_count_towards_limits increment_todays_requested_sms_count = mocker.patch("app.notifications.validators.increment_todays_requested_sms_count") def __send_sms(): - with set_config_values(notify_api, {"FF_SPIKE_SMS_DAILY_LIMIT": True, "REDIS_ENABLED": True}): + with set_config_values(notify_api, {"REDIS_ENABLED": True}): mocker.patch( "app.job.rest.get_job_metadata_from_s3", return_value={ @@ -1764,7 +1741,7 @@ def test_API_ONEOFF_sends_warning_emails_and_blocks_sends(self, notify_api, clie def __send_sms(): auth_header = create_authorization_header(service_id=template.service_id) - with set_config_values(notify_api, {"FF_SPIKE_SMS_DAILY_LIMIT": True, "REDIS_ENABLED": True}): + with set_config_values(notify_api, {"REDIS_ENABLED": True}): response = client.post( path="/v2/notifications/sms", data=json.dumps(data), @@ -1802,7 +1779,7 @@ def test_API_ONEOFF_cant_hop_over_limit_using_3_fragment_sms(self, notify_api, c def __send_sms(): auth_header = create_authorization_header(service_id=template.service_id) - with set_config_values(notify_api, {"FF_SPIKE_SMS_DAILY_LIMIT": True, "REDIS_ENABLED": True}): + with set_config_values(notify_api, {"REDIS_ENABLED": True}): response = client.post( path="/v2/notifications/sms", data=json.dumps(data), @@ -1837,7 +1814,7 @@ def test_API_BULK_sends_warning_emails_and_blocks_sends(self, notify_api, client send_limit_reached_email = mocker.patch("app.notifications.validators.send_sms_limit_reached_email") def __send_sms(): - with set_config_values(notify_api, {"FF_SPIKE_SMS_DAILY_LIMIT": True, "REDIS_ENABLED": True}): + with set_config_values(notify_api, {"REDIS_ENABLED": True}): data = { "name": "job_name", "template_id": str(template.id), @@ -1880,7 +1857,7 @@ def test_API_BULK_cant_hop_over_limit_1_fragment(self, notify_api, client, notif send_limit_reached_email = mocker.patch("app.notifications.validators.send_sms_limit_reached_email") def __send_sms(number_to_send=1): - with set_config_values(notify_api, {"FF_SPIKE_SMS_DAILY_LIMIT": True, "REDIS_ENABLED": True}): + with set_config_values(notify_api, {"REDIS_ENABLED": True}): numbers = [["9025551234"]] * number_to_send data = { "name": "job_name", @@ -1925,7 +1902,7 @@ def test_API_BULK_cant_hop_over_limit_2_fragment(self, notify_api, client, notif send_warning_email = mocker.patch("app.notifications.validators.send_near_sms_limit_email") def __send_sms(number_to_send=1): - with set_config_values(notify_api, {"FF_SPIKE_SMS_DAILY_LIMIT": True, "REDIS_ENABLED": True}): + with set_config_values(notify_api, {"REDIS_ENABLED": True}): numbers = [["9025551234"]] * number_to_send data = { "name": "job_name", @@ -1970,7 +1947,7 @@ def test_ADMIN_ONEOFF_sends_warning_emails_and_blocks_sends(self, notify_api, cl send_limit_reached_email = mocker.patch("app.notifications.validators.send_sms_limit_reached_email") def __send_sms(): - with set_config_values(notify_api, {"FF_SPIKE_SMS_DAILY_LIMIT": True, "REDIS_ENABLED": True}): + with set_config_values(notify_api, {"REDIS_ENABLED": True}): token = create_jwt_token( current_app.config["ADMIN_CLIENT_SECRET"], client_id=current_app.config["ADMIN_CLIENT_USER_NAME"] ) @@ -2014,7 +1991,7 @@ def test_ADMIN_ONEOFF_cant_hop_over_limit_using_3_fragment_sms( send_warning_email = mocker.patch("app.notifications.validators.send_near_sms_limit_email") def __send_sms(): - with set_config_values(notify_api, {"FF_SPIKE_SMS_DAILY_LIMIT": True, "REDIS_ENABLED": True}): + with set_config_values(notify_api, {"REDIS_ENABLED": True}): token = create_jwt_token( current_app.config["ADMIN_CLIENT_SECRET"], client_id=current_app.config["ADMIN_CLIENT_USER_NAME"] ) @@ -2057,7 +2034,7 @@ def test_ADMIN_CSV_sends_warning_emails_and_blocks_sends(self, notify_api, clien send_limit_reached_email = mocker.patch("app.notifications.validators.send_sms_limit_reached_email") def __send_sms(): - with set_config_values(notify_api, {"FF_SPIKE_SMS_DAILY_LIMIT": True, "REDIS_ENABLED": True}): + with set_config_values(notify_api, {"REDIS_ENABLED": True}): mocker.patch( "app.job.rest.get_job_metadata_from_s3", return_value={ @@ -2109,7 +2086,7 @@ def test_ADMIN_CSV_cant_hop_over_limit_using_1_fragment_sms(self, notify_api, cl send_limit_reached_email = mocker.patch("app.notifications.validators.send_sms_limit_reached_email") def __send_sms(number_to_send=1): - with set_config_values(notify_api, {"FF_SPIKE_SMS_DAILY_LIMIT": True, "REDIS_ENABLED": True}): + with set_config_values(notify_api, {"REDIS_ENABLED": True}): phone_numbers = "\r\n6502532222" * number_to_send mocker.patch("app.job.rest.get_job_from_s3", return_value=f"phone number{phone_numbers}") mocker.patch( @@ -2165,7 +2142,7 @@ def test_ADMIN_CSV_cant_hop_over_limit_using_2_fragment_sms(self, notify_api, cl send_limit_reached_email = mocker.patch("app.notifications.validators.send_sms_limit_reached_email") def __send_sms(number_to_send=1): - with set_config_values(notify_api, {"FF_SPIKE_SMS_DAILY_LIMIT": True, "REDIS_ENABLED": True}): + with set_config_values(notify_api, {"REDIS_ENABLED": True}): phone_numbers = "\r\n6502532222" * number_to_send mocker.patch("app.job.rest.get_job_from_s3", return_value=f"phone number{phone_numbers}") mocker.patch( @@ -2635,12 +2612,11 @@ def test_post_bulk_flags_not_enough_remaining_sms_messages(self, notify_api, cli "csv": rows_to_csv([["phone number"], ["6135551234"], ["6135551234"]]), } - with set_config(notify_api, "FF_SPIKE_SMS_DAILY_LIMIT", True): - response = client.post( - "/v2/notifications/bulk", - data=json.dumps(data), - headers=[("Content-Type", "application/json"), create_authorization_header(service_id=template.service_id)], - ) + response = client.post( + "/v2/notifications/bulk", + data=json.dumps(data), + headers=[("Content-Type", "application/json"), create_authorization_header(service_id=template.service_id)], + ) assert response.status_code == 400 error_json = json.loads(response.get_data(as_text=True)) @@ -2664,13 +2640,11 @@ def test_post_bulk_flags_not_enough_remaining_sms_message_parts( "template_id": template.id, "csv": rows_to_csv([["phone number"], ["6135551234"]]), } - - with set_config(notify_api, "FF_SPIKE_SMS_DAILY_LIMIT", True): - response = client.post( - "/v2/notifications/bulk", - data=json.dumps(data), - headers=[("Content-Type", "application/json"), create_authorization_header(service_id=template.service_id)], - ) + response = client.post( + "/v2/notifications/bulk", + data=json.dumps(data), + headers=[("Content-Type", "application/json"), create_authorization_header(service_id=template.service_id)], + ) assert response.status_code == 400 error_json = json.loads(response.get_data(as_text=True)) @@ -2681,30 +2655,6 @@ def test_post_bulk_flags_not_enough_remaining_sms_message_parts( } ] - def test_post_bulk_does_not_flag_not_enough_remaining_sms_message_parts_with_FF_SPIKE_SMS_DAILY_LIMIT_false( - self, notify_api, client, notify_db, notify_db_session, notify_user, mocker - ): - service = create_service(sms_daily_limit=10, message_limit=100) - template = create_sample_template(notify_db, notify_db_session, content=500 * "a", service=service, template_type="sms") - mocker.patch("app.v2.notifications.post_notifications.fetch_todays_requested_sms_count", return_value=9) - job_id = str(uuid.uuid4()) - mocker.patch("app.v2.notifications.post_notifications.upload_job_to_s3", return_value=job_id) - mocker.patch("app.v2.notifications.post_notifications.process_job.apply_async") - data = { - "name": "job_name", - "template_id": template.id, - "csv": rows_to_csv([["phone number"], ["6135551234"], ["6135551234"], ["6135551234"], ["6135551234"]]), - } - - with set_config(notify_api, "FF_SPIKE_SMS_DAILY_LIMIT", False): - response = client.post( - "/v2/notifications/bulk", - data=json.dumps(data), - headers=[("Content-Type", "application/json"), create_authorization_header(service_id=template.service_id)], - ) - - assert response.status_code == 201 - @pytest.mark.parametrize("data_type", ["rows", "csv"]) def test_post_bulk_flags_rows_with_errors(self, client, notify_db, notify_db_session, data_type): template = create_sample_template(notify_db, notify_db_session, template_type="email", content="Hello ((name))")