mirror of
https://github.com/GSA/notifications-api.git
synced 2026-09-09 12:59:48 -04:00
@@ -381,7 +381,7 @@ def setup_sqlalchemy_events(app):
|
|||||||
'host': current_app.config['NOTIFY_APP_NAME'], # worker name
|
'host': current_app.config['NOTIFY_APP_NAME'], # worker name
|
||||||
'url_rule': current_task.name, # task name
|
'url_rule': current_task.name, # task name
|
||||||
}
|
}
|
||||||
# anything else. migrations possibly.
|
# anything else. migrations possibly, or flask cli commands.
|
||||||
else:
|
else:
|
||||||
current_app.logger.warning('Checked out sqlalchemy connection from outside of request/task')
|
current_app.logger.warning('Checked out sqlalchemy connection from outside of request/task')
|
||||||
connection_record.info['request_data'] = {
|
connection_record.info['request_data'] = {
|
||||||
|
|||||||
@@ -52,11 +52,11 @@ def check_provider_message_should_send(broadcast_event, provider):
|
|||||||
"""
|
"""
|
||||||
current_provider_message = broadcast_event.get_provider_message(provider)
|
current_provider_message = broadcast_event.get_provider_message(provider)
|
||||||
# if this is the first time a task is being executed, it won't have a provider message yet
|
# if this is the first time a task is being executed, it won't have a provider message yet
|
||||||
if current_provider_message and current_provider_message.status == BroadcastProviderMessageStatus.TECHNICAL_FAILURE:
|
if current_provider_message and current_provider_message.status != BroadcastProviderMessageStatus.SENDING:
|
||||||
raise CBCProxyFatalException(
|
raise CBCProxyFatalException(
|
||||||
f'Cannot send broadcast_event {broadcast_event.id} ' +
|
f'Cannot send broadcast_event {broadcast_event.id} ' +
|
||||||
f'to provider {provider}: ' +
|
f'to provider {provider}: ' +
|
||||||
'It is already in status technical-failure'
|
f'It is in status {current_provider_message.status}'
|
||||||
)
|
)
|
||||||
|
|
||||||
if broadcast_event.transmitted_finishes_at < datetime.utcnow():
|
if broadcast_event.transmitted_finishes_at < datetime.utcnow():
|
||||||
|
|||||||
@@ -147,7 +147,7 @@ class CBCProxyClientBase(ABC):
|
|||||||
|
|
||||||
elif 'FunctionError' in result:
|
elif 'FunctionError' in result:
|
||||||
current_app.logger.info(
|
current_app.logger.info(
|
||||||
f"Error calling lambda {lambda_name} with function error { result['Payload'] }"
|
f"Error calling lambda {lambda_name} with function error { result['Payload'].read() }"
|
||||||
)
|
)
|
||||||
success = False
|
success = False
|
||||||
|
|
||||||
|
|||||||
@@ -701,15 +701,20 @@ def test_check_provider_message_should_send_doesnt_raise_if_newer_event_not_acke
|
|||||||
|
|
||||||
@pytest.mark.parametrize('existing_message_status', [
|
@pytest.mark.parametrize('existing_message_status', [
|
||||||
BroadcastProviderMessageStatus.SENDING,
|
BroadcastProviderMessageStatus.SENDING,
|
||||||
BroadcastProviderMessageStatus.ACK,
|
pytest.param(
|
||||||
BroadcastProviderMessageStatus.ERR,
|
BroadcastProviderMessageStatus.ACK,
|
||||||
|
marks=pytest.mark.xfail(raises=CBCProxyFatalException)
|
||||||
|
),
|
||||||
|
pytest.param(
|
||||||
|
BroadcastProviderMessageStatus.ERR,
|
||||||
|
marks=pytest.mark.xfail(raises=CBCProxyFatalException)
|
||||||
|
),
|
||||||
pytest.param(
|
pytest.param(
|
||||||
BroadcastProviderMessageStatus.TECHNICAL_FAILURE,
|
BroadcastProviderMessageStatus.TECHNICAL_FAILURE,
|
||||||
marks=pytest.mark.xfail(raises=CBCProxyFatalException)
|
marks=pytest.mark.xfail(raises=CBCProxyFatalException)
|
||||||
),
|
),
|
||||||
])
|
])
|
||||||
def test_check_provider_message_should_send_doesnt_raise_if_current_event_already_has_provider_message(
|
def test_check_provider_message_should_send_raises_if_current_event_already_has_provider_message_not_in_sending(
|
||||||
sample_template,
|
sample_template,
|
||||||
existing_message_status
|
existing_message_status
|
||||||
):
|
):
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
from io import BytesIO
|
||||||
import json
|
import json
|
||||||
import uuid
|
import uuid
|
||||||
from collections import namedtuple
|
from collections import namedtuple
|
||||||
@@ -380,10 +381,7 @@ def test_cbc_proxy_will_failover_to_second_lambda_if_function_error(
|
|||||||
{
|
{
|
||||||
'StatusCode': 200,
|
'StatusCode': 200,
|
||||||
'FunctionError': 'Handled',
|
'FunctionError': 'Handled',
|
||||||
'Payload': {
|
'Payload': BytesIO(json.dumps({"errorMessage": "", "errorType": "CBCNewConnectionError"}).encode('utf-8')),
|
||||||
"errorMessage": "",
|
|
||||||
"errorType": "CBCNewConnectionError"
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
'StatusCode': 200
|
'StatusCode': 200
|
||||||
@@ -522,10 +520,7 @@ def test_cbc_proxy_create_and_send_tries_failover_lambda_on_function_error_and_r
|
|||||||
ld_client_mock.invoke.return_value = {
|
ld_client_mock.invoke.return_value = {
|
||||||
'StatusCode': 200,
|
'StatusCode': 200,
|
||||||
'FunctionError': 'something',
|
'FunctionError': 'something',
|
||||||
'Payload': {
|
'Payload': BytesIO(json.dumps({"errorMessage": "some message", "errorType": "SomeErrorType"}).encode('utf-8')),
|
||||||
'errorMessage': 'some message',
|
|
||||||
'errorType': 'SomeErrorType'
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
with pytest.raises(CBCProxyRetryableException) as e:
|
with pytest.raises(CBCProxyRetryableException) as e:
|
||||||
|
|||||||
Reference in New Issue
Block a user