-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2692fde
commit 01c6c33
Showing
5 changed files
with
73 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,7 +28,8 @@ | |
has_full_refund_transaction, | ||
has_refund_transaction, | ||
send_order_confirmation_email, | ||
translate_stripe_refund_status_to_transaction_status | ||
send_unsupported_mode_fulfillment_error_email, | ||
translate_stripe_refund_status_to_transaction_status, | ||
) | ||
|
||
|
||
|
@@ -126,6 +127,60 @@ def test_send_order_confirmation_email_failure(self, mock_logger, mock_get_braze | |
mock_logger.assert_called_once_with('Encountered exception sending Order confirmation email. ' | ||
'Exception: Error sending Braze email') | ||
|
||
@override_settings( | ||
BRAZE_API_KEY="braze_api_key", | ||
BRAZE_API_SERVER="braze_api_server", | ||
BRAZE_CT_FULFILLMENT_UNSUPPORTED_MODE_ERROR_CANVAS_ID="dummy_canvas" | ||
) | ||
@patch('commerce_coordinator.apps.commercetools.utils.get_braze_client') | ||
def test_send_unsupported_mode_fulfillment_error_email_success(self, mock_get_braze_client): | ||
mock_braze_client = Mock() | ||
mock_get_braze_client.return_value = mock_braze_client | ||
|
||
canvas_entry_properties = {} | ||
lms_user_id = 'user123' | ||
lms_user_email = '[email protected]' | ||
|
||
with patch.object(mock_braze_client, 'send_canvas_message') as mock_send_canvas_message: | ||
send_unsupported_mode_fulfillment_error_email( | ||
lms_user_id, lms_user_email, canvas_entry_properties | ||
) | ||
|
||
mock_send_canvas_message.assert_called_once_with( | ||
canvas_id='dummy_canvas', | ||
recipients=[{"external_user_id": lms_user_id, "attributes": {"email": lms_user_email}}], | ||
canvas_entry_properties=canvas_entry_properties, | ||
) | ||
|
||
@override_settings( | ||
BRAZE_API_KEY="braze_api_key", | ||
BRAZE_API_SERVER="braze_api_server", | ||
BRAZE_CT_FULFILLMENT_UNSUPPORTED_MODE_ERROR_CANVAS_ID="dummy_canvas" | ||
) | ||
@patch('commerce_coordinator.apps.commercetools.utils.get_braze_client') | ||
@patch('commerce_coordinator.apps.commercetools.utils.logger.exception') | ||
def test_send_unsupported_mode_fulfillment_error_email_failure(self, mock_logger, mock_get_braze_client): | ||
mock_braze_client = Mock() | ||
mock_get_braze_client.return_value = mock_braze_client | ||
|
||
canvas_entry_properties = {} | ||
lms_user_id = 'user123' | ||
lms_user_email = '[email protected]' | ||
|
||
with patch.object(mock_braze_client, 'send_canvas_message') as mock_send_canvas_message: | ||
mock_send_canvas_message.side_effect = Exception('Error sending Braze email') | ||
send_unsupported_mode_fulfillment_error_email( | ||
lms_user_id, lms_user_email, canvas_entry_properties | ||
) | ||
|
||
mock_send_canvas_message.assert_called_once_with( | ||
canvas_id='dummy_canvas', | ||
recipients=[{"external_user_id": lms_user_id, "attributes": {"email": lms_user_email}}], | ||
canvas_entry_properties=canvas_entry_properties, | ||
) | ||
mock_logger.assert_called_once_with('Encountered exception sending Fulfillment unsupported mode error ' | ||
'email. Exception: Error sending Braze email') | ||
|
||
def test_extract_ct_product_information_for_braze_canvas(self): | ||
order = gen_order(EXAMPLE_FULFILLMENT_SIGNAL_PAYLOAD['order_number']) | ||
line_item = order.line_items[0] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters