spell receive correctly when discounting

This commit is contained in:
Emma Green
2019-05-15 09:54:20 -04:00
parent 6439070121
commit 7bcce26f85
5 changed files with 14 additions and 14 deletions

View File

@@ -412,7 +412,7 @@ class TestCourseHomePageAccess(CourseHomePageTestCase):
@override_waffle_flag(FIRST_PURCHASE_OFFER_BANNER_DISPLAY, active=True)
@mock.patch('openedx.features.course_experience.utils.discount_percentage')
@mock.patch('openedx.features.course_experience.utils.can_recieve_discount')
@mock.patch('openedx.features.course_experience.utils.can_receive_discount')
@ddt.data(
[True, 15],
[True, 13],
@@ -422,12 +422,12 @@ class TestCourseHomePageAccess(CourseHomePageTestCase):
def test_first_purchase_offer_banner_display(self,
applicability,
percentage,
can_recieve_discount_mock,
can_receive_discount_mock,
discount_percentage_mock):
"""
Ensure first purchase offer banner displays correctly
"""
can_recieve_discount_mock.return_value = applicability
can_receive_discount_mock.return_value = applicability
discount_percentage_mock.return_value = percentage
user = self.create_user_for_course(self.course, CourseUserType.ENROLLED)
self.client.login(username=user.username, password=self.TEST_PASSWORD)

View File

@@ -14,7 +14,7 @@ from lms.djangoapps.course_blocks.utils import get_student_module_as_dict
from openedx.core.djangolib.markup import HTML
from openedx.core.lib.cache_utils import request_cached
from openedx.features.course_experience import FIRST_PURCHASE_OFFER_BANNER_DISPLAY
from openedx.features.discounts.applicability import can_recieve_discount, discount_percentage
from openedx.features.discounts.applicability import can_receive_discount, discount_percentage
from xmodule.modulestore.django import modulestore
@@ -196,7 +196,7 @@ def get_first_purchase_offer_banner_fragment(user, course):
if (FIRST_PURCHASE_OFFER_BANNER_DISPLAY.is_enabled() and
user and
course and
can_recieve_discount(user=user, course_key_string=unicode(course.id))):
can_receive_discount(user=user, course_key_string=unicode(course.id))):
# Translator: xgettext:no-python-format
offer_message = _(u'{banner_open}{percentage}% off your first upgrade.{span_close}'
u' Discount automatically applied.{div_close}')

View File

@@ -23,10 +23,10 @@ DISCOUNT_APPLICABILITY_FLAG = WaffleFlag(
)
def can_recieve_discount(user, course_key_string): # pylint: disable=unused-argument
def can_receive_discount(user, course_key_string): # pylint: disable=unused-argument
"""
Check all the business logic about whether this combination of user and course
can recieve a discount.
can receive a discount.
"""
# Always disable discounts until we are ready to enable this feature
if not DISCOUNT_APPLICABILITY_FLAG.is_enabled():

View File

@@ -5,7 +5,7 @@ from student.tests.factories import UserFactory
from xmodule.modulestore.tests.django_utils import ModuleStoreTestCase
from xmodule.modulestore.tests.factories import CourseFactory
from ..applicability import can_recieve_discount
from ..applicability import can_receive_discount
class TestApplicability(ModuleStoreTestCase):
@@ -19,7 +19,7 @@ class TestApplicability(ModuleStoreTestCase):
self.user = UserFactory.create()
self.course = CourseFactory.create(run='test', display_name='test')
def test_can_recieve_discount(self):
# Right now, no one should be able to recieve the discount
applicability = can_recieve_discount(user=self.user, course_key_string=self.course.id)
def test_can_receive_discount(self):
# Right now, no one should be able to receive the discount
applicability = can_receive_discount(user=self.user, course_key_string=self.course.id)
self.assertEqual(applicability, False)

View File

@@ -17,7 +17,7 @@ from rest_framework.response import Response
from rest_framework.views import APIView
from django.utils.decorators import method_decorator
from .applicability import can_recieve_discount, discount_percentage
from .applicability import can_receive_discount, discount_percentage
class CourseUserDiscount(DeveloperErrorViewMixin, APIView):
@@ -34,7 +34,7 @@ class CourseUserDiscount(DeveloperErrorViewMixin, APIView):
Body consists of the following fields:
discount_applicable:
whether the user can recieve a discount for this course
whether the user can receive a discount for this course
jwt:
the jwt with user information and discount information
@@ -65,7 +65,7 @@ class CourseUserDiscount(DeveloperErrorViewMixin, APIView):
"""
Return the discount percent, if the user has appropriate permissions.
"""
discount_applicable = can_recieve_discount(user=request.user, course_key_string=course_key_string)
discount_applicable = can_receive_discount(user=request.user, course_key_string=course_key_string)
discount_percent = discount_percentage()
payload = {'discount_applicable': discount_applicable, 'discount_percent': discount_percent}
return Response({