From 7ecaeb56e01601ea4bef336e7f6009159253155d Mon Sep 17 00:00:00 2001 From: Stephen Astels Date: Wed, 5 Jun 2024 13:41:49 -0400 Subject: [PATCH] use empty string for default pool id value --- app/config.py | 4 ++-- app/delivery/send_to_providers.py | 5 ++--- tests/app/delivery/test_send_to_providers.py | 6 +++--- 3 files changed, 7 insertions(+), 8 deletions(-) diff --git a/app/config.py b/app/config.py index aab8422f27..b8b6521ad5 100644 --- a/app/config.py +++ b/app/config.py @@ -266,8 +266,8 @@ class Config(object): AWS_SES_ACCESS_KEY = os.getenv("AWS_SES_ACCESS_KEY") AWS_SES_SECRET_KEY = os.getenv("AWS_SES_SECRET_KEY") AWS_PINPOINT_REGION = os.getenv("AWS_PINPOINT_REGION", "us-west-2") - AWS_PINPOINT_SC_POOL_ID = os.getenv("AWS_PINPOINT_SC_POOL_ID", None) - AWS_PINPOINT_DEFAULT_POOL_ID = os.getenv("AWS_PINPOINT_DEFAULT_POOL_ID", None) + AWS_PINPOINT_SC_POOL_ID = os.getenv("AWS_PINPOINT_SC_POOL_ID", "") + AWS_PINPOINT_DEFAULT_POOL_ID = os.getenv("AWS_PINPOINT_DEFAULT_POOL_ID", "") AWS_PINPOINT_CONFIGURATION_SET_NAME = os.getenv("AWS_PINPOINT_CONFIGURATION_SET_NAME", "pinpoint-configuration") AWS_PINPOINT_SC_TEMPLATE_IDS = env.list("AWS_PINPOINT_SC_TEMPLATE_IDS", []) AWS_US_TOLL_FREE_NUMBER = os.getenv("AWS_US_TOLL_FREE_NUMBER") diff --git a/app/delivery/send_to_providers.py b/app/delivery/send_to_providers.py index 5f74f76033..5ef24c0769 100644 --- a/app/delivery/send_to_providers.py +++ b/app/delivery/send_to_providers.py @@ -379,10 +379,9 @@ def provider_to_use( do_not_use_pinpoint = ( has_dedicated_number or sending_to_us_number - or current_app.config["AWS_PINPOINT_SC_POOL_ID"] is None - or (current_app.config["AWS_PINPOINT_DEFAULT_POOL_ID"] is None and not using_sc_pool_template) + or not current_app.config["AWS_PINPOINT_SC_POOL_ID"] + or ((not current_app.config["AWS_PINPOINT_DEFAULT_POOL_ID"]) and not using_sc_pool_template) ) - if do_not_use_pinpoint: active_providers_in_order = [ p diff --git a/tests/app/delivery/test_send_to_providers.py b/tests/app/delivery/test_send_to_providers.py index 6b7dbf2210..0768d98cc9 100644 --- a/tests/app/delivery/test_send_to_providers.py +++ b/tests/app/delivery/test_send_to_providers.py @@ -68,7 +68,7 @@ def test_should_use_sns_for_sms_by_default_if_partially_configured(self, restore notify_api, { "AWS_PINPOINT_SC_POOL_ID": "sc_pool_id", - "AWS_PINPOINT_DEFAULT_POOL_ID": None, + "AWS_PINPOINT_DEFAULT_POOL_ID": "", "AWS_PINPOINT_SC_TEMPLATE_IDS": [], }, ): @@ -81,7 +81,7 @@ def test_should_use_pinpoint_for_sms_for_sc_template_if_sc_pool_configured(self, notify_api, { "AWS_PINPOINT_SC_POOL_ID": "sc_pool_id", - "AWS_PINPOINT_DEFAULT_POOL_ID": None, + "AWS_PINPOINT_DEFAULT_POOL_ID": "", "AWS_PINPOINT_SC_TEMPLATE_IDS": [str(sc_template)], }, ): @@ -110,7 +110,7 @@ def test_should_use_sns_for_sms_if_sending_to_the_US(self, restore_provider_deta provider = send_to_providers.provider_to_use("sms", "1234", "+17065551234") assert provider.name == "sns" - @pytest.mark.parametrize("sc_pool_id, default_pool_id", [(None, "default_pool_id"), ("sc_pool_id", None)]) + @pytest.mark.parametrize("sc_pool_id, default_pool_id", [("", "default_pool_id"), ("sc_pool_id", "")]) def test_should_use_sns_if_pinpoint_not_configured(self, restore_provider_details, notify_api, sc_pool_id, default_pool_id): with set_config_values( notify_api,