Generate Vodafone link test sequence nos in proxy

Previously the Celery task to trigger a link test had to know about
the special case of a sequence number for Vodafone. Since we're about
to change the client to perform multiple tests it makes sense to give
it the knowledge of how to generate number itself.

Note that we have to import the db inline to avoid a circular import,
since this module is itself imported by app/__init__.py.

Other invocations of the Vodafone client use stored sequence numbers
from the DB, which are called "message numbers" in that context. Since
the two use cases are very different (even the names are different!),
having them in two places shouldn't cause any confusion.
This commit is contained in:
Ben Thorner
2021-07-19 12:48:18 +01:00
parent d781da2981
commit b6774bf0f7
4 changed files with 19 additions and 33 deletions

View File

@@ -8,6 +8,7 @@ from unittest.mock import Mock, call
import pytest
from botocore.exceptions import ClientError as BotoClientError
from app import db
from app.clients.cbc_proxy import (
CBCProxyClient,
CBCProxyEE,
@@ -573,7 +574,6 @@ def test_cbc_proxy_one_2_many_send_link_test_invokes_function(mocker, cbc_proxy_
cbc_proxy.send_link_test(
identifier=identifier,
sequential_number='0000007b',
)
ld_client_mock.invoke.assert_called_once_with(
@@ -595,6 +595,10 @@ def test_cbc_proxy_one_2_many_send_link_test_invokes_function(mocker, cbc_proxy_
def test_cbc_proxy_vodafone_send_link_test_invokes_function(mocker, cbc_proxy_vodafone):
identifier = str(uuid.uuid4())
db.session.connection().execute(
'ALTER SEQUENCE broadcast_provider_message_number_seq RESTART WITH 1'
)
ld_client_mock = mocker.patch.object(
cbc_proxy_vodafone,
'_lambda_client',
@@ -607,7 +611,6 @@ def test_cbc_proxy_vodafone_send_link_test_invokes_function(mocker, cbc_proxy_vo
cbc_proxy_vodafone.send_link_test(
identifier=identifier,
sequential_number='0000007b',
)
ld_client_mock.invoke.assert_called_once_with(
@@ -622,5 +625,5 @@ def test_cbc_proxy_vodafone_send_link_test_invokes_function(mocker, cbc_proxy_vo
assert payload['identifier'] == identifier
assert payload['message_type'] == 'test'
assert payload['message_number'] == '0000007b'
assert payload['message_number'] == '00000001'
assert payload['message_format'] == 'ibag'