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

@@ -2,9 +2,8 @@ import uuid
from datetime import datetime
from flask import current_app
from sqlalchemy.schema import Sequence
from app import cbc_proxy_client, db, notify_celery, zendesk_client
from app import cbc_proxy_client, notify_celery, zendesk_client
from app.clients.cbc_proxy import CBCProxyRetryableException
from app.config import QueueNames
from app.dao.broadcast_message_dao import (
@@ -252,11 +251,6 @@ def send_broadcast_provider_message(self, broadcast_event_id, provider):
@notify_celery.task(name='trigger-link-test')
def trigger_link_test(provider):
identifier = str(uuid.uuid4())
formatted_seq_number = None
if provider == BroadcastProvider.VODAFONE:
sequence = Sequence('broadcast_provider_message_number_seq')
sequential_number = db.session.connection().execute(sequence)
formatted_seq_number = format_sequential_number(sequential_number)
message = f"Sending a link test to CBC proxy for provider {provider}. Identifier in payload is {identifier}"
current_app.logger.info(message)
cbc_proxy_client.get_proxy(provider).send_link_test(identifier, formatted_seq_number)
cbc_proxy_client.get_proxy(provider).send_link_test(identifier)