diff --git a/commerce_coordinator/apps/commercetools/tests/test_clients.py b/commerce_coordinator/apps/commercetools/tests/test_clients.py index 1e66b5d7..ff17e316 100644 --- a/commerce_coordinator/apps/commercetools/tests/test_clients.py +++ b/commerce_coordinator/apps/commercetools/tests/test_clients.py @@ -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, @@ -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') diff --git a/commerce_coordinator/apps/commercetools/utils.py b/commerce_coordinator/apps/commercetools/utils.py index 1f243bd2..8f4f6ca6 100644 --- a/commerce_coordinator/apps/commercetools/utils.py +++ b/commerce_coordinator/apps/commercetools/utils.py @@ -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(