check if discount expired

This commit is contained in:
Matthew Piatetsky
2019-10-02 16:52:59 -04:00
parent 8aa2fad4ec
commit f6d0bf77df
8 changed files with 133 additions and 25 deletions

View File

@@ -25,6 +25,7 @@ from experiments.models import ExperimentData
from lms.djangoapps.commerce.models import CommerceConfiguration
from lms.djangoapps.commerce.utils import EcommerceService
from lms.djangoapps.course_goals.api import add_course_goal, remove_course_goal
from lms.djangoapps.courseware.date_summary import verified_upgrade_deadline_link
from lms.djangoapps.courseware.tests.factories import (
BetaTesterFactory,
GlobalStaffFactory,
@@ -34,6 +35,8 @@ from lms.djangoapps.courseware.tests.factories import (
StaffFactory
)
from lms.djangoapps.discussion.django_comment_client.tests.factories import RoleFactory
from openedx.features.discounts.applicability import get_discount_expiration_date
from openedx.features.discounts.utils import format_strikeout_price
from openedx.core.djangoapps.content.course_overviews.models import CourseOverview
from openedx.core.djangoapps.dark_lang.models import DarkLangConfig
from openedx.core.djangoapps.django_comment_common.models import (
@@ -217,7 +220,7 @@ class TestCourseHomePage(CourseHomePageTestCase):
# Fetch the view and verify the query counts
# TODO: decrease query count as part of REVO-28
with self.assertNumQueries(95, table_blacklist=QUERY_COUNT_TABLE_BLACKLIST):
with self.assertNumQueries(97, table_blacklist=QUERY_COUNT_TABLE_BLACKLIST):
with check_mongo_calls(4):
url = course_home_url(self.course)
self.client.get(url)
@@ -432,11 +435,19 @@ class TestCourseHomePageAccess(CourseHomePageTestCase):
self.client.login(username=user.username, password=self.TEST_PASSWORD)
url = course_home_url(self.course)
response = self.client.get(url)
discount_expiration_date = get_discount_expiration_date(user, self.course).strftime(u'%B %d')
upgrade_link = verified_upgrade_deadline_link(user=user, course=self.course)
bannerText = u'''<div class="first-purchase-offer-banner">
<span class="first-purchase-offer-banner-bold">
{}% off your first upgrade.
</span> Discount automatically applied.
</div>'''.format(percentage)
<span class="first-purchase-offer-banner-bold">
Upgrade by {discount_expiration_date} and save {percentage}% [{strikeout_price}]</span>
<br>Discount will be automatically applied at checkout. <a href="{upgrade_link}">Upgrade Now</a>
</div>'''.format(
discount_expiration_date=discount_expiration_date,
percentage=percentage,
strikeout_price=HTML(format_strikeout_price(user, self.course, check_for_discount=False)[0]),
upgrade_link=upgrade_link
)
if applicability:
self.assertContains(response, bannerText, html=True)
else: