-
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.
Merge branch 'main' into bilalqamar95/dockerfile-setup-removal
- Loading branch information
Showing
15 changed files
with
235 additions
and
9 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
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
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,6 +28,7 @@ | |
has_full_refund_transaction, | ||
has_refund_transaction, | ||
send_order_confirmation_email, | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,7 +29,10 @@ | |
'line_item_id': '822d77c4-00a6-4fb9-909b-094ef0b8c4b9', | ||
'item_quantity': 1, | ||
'line_item_state_id': '8f2e888e-9777-4557-9a7f-c649153770c2', | ||
'message_id': '1063f19c-08f3-41a4-a952-a8577374373c' | ||
'message_id': '1063f19c-08f3-41a4-a952-a8577374373c', | ||
'user_first_name': 'test', | ||
'user_email': '[email protected]', | ||
'course_title': 'Demonstration Course', | ||
} | ||
|
||
EXAMPLE_FULFILLMENT_REQUEST_PAYLOAD = { | ||
|
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
Oops, something went wrong.