Skip to content

Commit

Permalink
fix: fixed unit tests and linting issues
Browse files Browse the repository at this point in the history
  • Loading branch information
abdullahwaheed committed Nov 13, 2024
1 parent db9024c commit 0c7124c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
4 changes: 2 additions & 2 deletions commerce_coordinator/apps/commercetools/tests/test_clients.py
Original file line number Diff line number Diff line change
Expand Up @@ -672,7 +672,7 @@ def test_update_line_item_state_exception(self, mock_state_by_id):
status_code=409
)

with patch('commerce_coordinator.apps.commercetools.clients.logging.Logger.error') as log_mock:
with patch('commerce_coordinator.apps.commercetools.clients.logging.Logger.info') as log_mock:
self.client_set.client.update_line_item_transition_state_on_fulfillment(
"mock_order_id",
1,
Expand All @@ -689,7 +689,7 @@ def test_update_line_item_state_exception(self, mock_state_by_id):
f"Details: {mock_error_response['errors']}"
)

log_mock.assert_called_once_with(expected_message)
log_mock.assert_called_with(expected_message)

@patch('commerce_coordinator.apps.commercetools.clients.CommercetoolsAPIClient.get_state_by_id')
@patch('commerce_coordinator.apps.commercetools.clients.CommercetoolsAPIClient.get_order_by_id')
Expand Down
6 changes: 5 additions & 1 deletion commerce_coordinator/apps/commercetools/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,12 @@ def get_braze_client():


def handle_commercetools_error(err: CommercetoolsError, context: str, is_info=False):
"""Handles commercetools errors."""
error_message = f"[CommercetoolsError] {context} - Correlation ID: {err.correlation_id}, Details: {err.errors}"
logger.info(error_message) if is_info else logger.error(error_message)
if is_info:
logger.info(error_message)
else:
logger.error(error_message)


def send_order_confirmation_email(
Expand Down

0 comments on commit 0c7124c

Please sign in to comment.