From cdc150de1b92eb9a4dc393948ccf4e33fce91ee4 Mon Sep 17 00:00:00 2001 From: Ben Thorner Date: Mon, 19 Jul 2021 15:09:55 +0100 Subject: [PATCH] Change link test task to trigger both lambda This modifies the previous "(_)send_link_test" method to trigger a link test for a specific lambda. We then call the method with both the primary and failover lambda in new orchestrator method. Since the _invoke_lambda function doesn't raise exceptions if it fails, there's no need to rescue anything in order to ensure the second link test / invocation runs as well. It doesn't testing for this, since it boils to an absence of code to raise any exception. Note that, like the other parent tests, we only check the new method works with a specific proxy client instance. --- app/celery/broadcast_message_tasks.py | 2 +- app/clients/cbc_proxy.py | 7 +++++-- tests/app/clients/test_cbc_proxy.py | 4 ++-- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/app/celery/broadcast_message_tasks.py b/app/celery/broadcast_message_tasks.py index 05b5ba7da..8a5d2ef99 100644 --- a/app/celery/broadcast_message_tasks.py +++ b/app/celery/broadcast_message_tasks.py @@ -249,4 +249,4 @@ def send_broadcast_provider_message(self, broadcast_event_id, provider): @notify_celery.task(name='trigger-link-test') def trigger_link_test(provider): - cbc_proxy_client.get_proxy(provider).send_link_tests() + cbc_proxy_client.get_proxy(provider).send_link_test() diff --git a/app/clients/cbc_proxy.py b/app/clients/cbc_proxy.py index b6216effe..60f30f0ae 100644 --- a/app/clients/cbc_proxy.py +++ b/app/clients/cbc_proxy.py @@ -78,11 +78,14 @@ class CBCProxyClientBase(ABC): def __init__(self, lambda_client): self._lambda_client = lambda_client - def send_link_tests(self): + def send_link_test(self): self._send_link_test(self.lambda_name) self._send_link_test(self.failover_lambda_name) - def _send_link_test(self): pass + def _send_link_test( + self, + lambda_name, + ): pass def create_and_send_broadcast( self, identifier, headline, description, areas, sent, expires, channel, message_number=None diff --git a/tests/app/clients/test_cbc_proxy.py b/tests/app/clients/test_cbc_proxy.py index f067c47c0..83fa994fc 100644 --- a/tests/app/clients/test_cbc_proxy.py +++ b/tests/app/clients/test_cbc_proxy.py @@ -82,9 +82,9 @@ def test_cbc_proxy_lambda_client_has_correct_keys(cbc_proxy_ee): assert secret == 'cbc-proxy-aws-secret-access-key' -def test_cbc_proxy_send_link_tests(mocker, cbc_proxy_ee): +def test_cbc_proxy_send_link_test(mocker, cbc_proxy_ee): mock_send_link_test = mocker.patch.object(cbc_proxy_ee, '_send_link_test') - cbc_proxy_ee.send_link_tests() + cbc_proxy_ee.send_link_test() mock_send_link_test.assert_any_call(cbc_proxy_ee.lambda_name) mock_send_link_test.assert_any_call(cbc_proxy_ee.failover_lambda_name)