Pass message_number to proxy clients

This commit is contained in:
Pea Tyczynska
2020-12-04 17:29:12 +00:00
parent e95dc9450e
commit 932a09fe5b
2 changed files with 27 additions and 49 deletions

View File

@@ -62,16 +62,30 @@ class CBCProxyClientBase:
def send_link_test(
self,
identifier,
sequential_number=None
sequential_number
):
pass
"""
link test - open up a connection to a specific provider, and send them an xml payload with a <msgType> of
test.
"""
payload = {'message_type': 'test', 'identifier': identifier, 'message_number': sequential_number}
self._invoke_lambda(payload=payload)
def create_and_send_broadcast(
self,
identifier, headline, description, areas,
sent, expires,
self, identifier, message_number, headline, description, areas, sent, expires,
):
pass
payload = {
'message_type': 'alert',
'identifier': identifier,
'message_number': message_number,
'headline': headline,
'description': description,
'areas': areas,
'sent': sent,
'expires': expires,
}
self._invoke_lambda(payload=payload)
# We have not implementated updating a broadcast
def update_and_send_broadcast(
@@ -130,48 +144,6 @@ class CBCProxyCanary(CBCProxyClientBase):
class CBCProxyEE(CBCProxyClientBase):
lambda_name = 'bt-ee-1-proxy'
def send_link_test(
self,
identifier,
sequential_number=None
):
"""
link test - open up a connection to a specific provider, and send them an xml payload with a <msgType> of
test.
"""
payload = {'message_type': 'test', 'identifier': identifier}
self._invoke_lambda(payload=payload)
def create_and_send_broadcast(
self,
identifier, headline, description, areas,
sent, expires,
):
payload = {
'message_type': 'alert',
'identifier': identifier,
'headline': headline,
'description': description,
'areas': areas,
'sent': sent,
'expires': expires,
}
self._invoke_lambda(payload=payload)
class CBCProxyVodafone(CBCProxyClientBase):
lambda_name = 'bt-ee-1-proxy'
def send_link_test(
self,
identifier,
sequential_number
):
"""
link test - open up a connection to a specific provider, and send them an xml payload with a <msgType> of
test.
"""
payload = {'message_type': 'test', 'identifier': identifier, 'message_number': sequential_number}
self._invoke_lambda(payload=payload)
lambda_name = 'vodafone-1-proxy'

View File

@@ -83,6 +83,7 @@ def test_cbc_proxy_create_and_send_invokes_function(mocker, cbc_proxy_ee):
cbc_proxy_ee.create_and_send_broadcast(
identifier=identifier,
message_number='0000007b',
headline=headline,
description=description,
areas=areas,
@@ -100,6 +101,7 @@ def test_cbc_proxy_create_and_send_invokes_function(mocker, cbc_proxy_ee):
payload = json.loads(payload_bytes)
assert payload['identifier'] == identifier
assert payload['message_number'] == '0000007b'
assert payload['message_type'] == 'alert'
assert payload['headline'] == headline
assert payload['description'] == description
@@ -141,6 +143,7 @@ def test_cbc_proxy_create_and_send_handles_invoke_error(mocker, cbc_proxy_ee):
with pytest.raises(CBCProxyException) as e:
cbc_proxy_ee.create_and_send_broadcast(
identifier=identifier,
message_number='0000007b',
headline=headline,
description=description,
areas=areas,
@@ -190,6 +193,7 @@ def test_cbc_proxy_create_and_send_handles_function_error(mocker, cbc_proxy_ee):
with pytest.raises(CBCProxyException) as e:
cbc_proxy_ee.create_and_send_broadcast(
identifier=identifier,
message_number='0000007b',
headline=headline,
description=description,
areas=areas,
@@ -252,6 +256,7 @@ def test_cbc_proxy_send_link_test_invokes_function(mocker, cbc_proxy_ee):
cbc_proxy_ee.send_link_test(
identifier=identifier,
sequential_number='0000007b'
)
ld_client_mock.invoke.assert_called_once_with(
@@ -266,3 +271,4 @@ def test_cbc_proxy_send_link_test_invokes_function(mocker, cbc_proxy_ee):
assert payload['identifier'] == identifier
assert payload['message_type'] == 'test'
assert payload['message_number'] == '0000007b'