Skip to content
Snippets Groups Projects
Unverified Commit 610ce48f authored by Hasnain Naveed's avatar Hasnain Naveed Committed by GitHub
Browse files

Merge pull request #23736 from edx/hasnain-naveed/ENT-2735-logging-message

ENT-2735 | Added more logging for e-commerce calculate endpoint.
parents d0decc3d dcace9cb
No related merge requests found
""" Helper methods for CourseModes. """
import logging
import six
from django.utils.translation import ugettext_lazy as _
......@@ -16,6 +17,8 @@ DISPLAY_HONOR = "honor"
DISPLAY_AUDIT = "audit"
DISPLAY_PROFESSIONAL = "professional"
LOGGER = logging.getLogger(__name__)
def enrollment_mode_display(mode, verification_status, course_id):
""" Select appropriate display strings and CSS classes.
......@@ -99,6 +102,18 @@ def get_course_final_price(user, sku, course_price):
sku=[sku],
username=user.username,
)
except (SlumberBaseException, ConnectionError, Timeout) as exc: # pylint: disable=unused-variable
pass
except (SlumberBaseException, ConnectionError, Timeout) as exc:
LOGGER.info(
'[e-commerce calculate endpoint] Exception raise for sku [%s] - user [%s] and exception: %s',
sku,
user.username,
str(exc)
)
LOGGER.info(
'[e-commerce calculate endpoint] The discounted price for sku [%s] and user [%s] is [%s]',
sku,
user.username,
price_details.get('total_incl_tax')
)
return price_details.get('total_incl_tax', course_price)
......@@ -222,7 +222,7 @@ class CourseModeViewTest(CatalogIntegrationMixin, UrlResetMixin, ModuleStoreTest
user=self.user
)
mock_enterprise_customer_for_request.return_value = is_enterprise_enabled
mock_enterprise_customer_for_request.return_value = {'name': 'dummy'} if is_enterprise_enabled else {}
mock_get_course_final_price.return_value = discounted_price
url = reverse('course_modes_choose', args=[self.course.id])
response = self.client.get(url)
......
......@@ -206,6 +206,11 @@ class ChooseModeView(View):
price_before_discount = verified_mode.min_price
course_price = price_before_discount
enterprise_customer = enterprise_customer_for_request(request)
LOG.info(
'[e-commerce calculate API] Going to hit the API for user [%s] linked to [%s] enterprise',
request.user.username,
enterprise_customer.get('name') if isinstance(enterprise_customer, dict) else None # Test Purpose
)
if enterprise_customer and verified_mode.sku:
course_price = get_course_final_price(request.user, verified_mode.sku, price_before_discount)
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment