Commit 45fbd156 by Clinton Blackburn Committed by Clinton Blackburn

Removed SAILTHRU_MINIMUM_COST

Sailthru now supports $0 purchases. SAILTHRU_MINIMUM_COST has been removed as it is no longer needed.

LEARNER-1519
parent d598cbb2
...@@ -84,10 +84,6 @@ SAILTHRU = { ...@@ -84,10 +84,6 @@ SAILTHRU = {
# ttl for cached course content from Sailthru (in seconds) # ttl for cached course content from Sailthru (in seconds)
'SAILTHRU_CACHE_TTL_SECONDS': 3600, 'SAILTHRU_CACHE_TTL_SECONDS': 3600,
# dummy price for audit/honor (i.e., if cost = 0)
# Note: setting this value to 0 skips Sailthru calls for free transactions
'SAILTHRU_MINIMUM_COST': 100,
# Transactional email template name map # Transactional email template name map
'templates': { 'templates': {
'course_refund': 'Course Refund', 'course_refund': 'Course Refund',
......
...@@ -276,11 +276,6 @@ def update_course_enrollment(self, email, course_url, purchase_incomplete, mode, ...@@ -276,11 +276,6 @@ def update_course_enrollment(self, email, course_url, purchase_incomplete, mode,
# calc price in pennies for Sailthru # calc price in pennies for Sailthru
# https://getstarted.sailthru.com/new-for-developers-overview/advanced-features/purchase/ # https://getstarted.sailthru.com/new-for-developers-overview/advanced-features/purchase/
cost_in_cents = int(unit_cost * 100) cost_in_cents = int(unit_cost * 100)
if not cost_in_cents:
cost_in_cents = config.get('SAILTHRU_MINIMUM_COST')
# if still zero, ignore purchase since Sailthru can't deal with $0 transactions
if not cost_in_cents:
return
# update the "unenrolled" course array in the user record on Sailthru if new enroll or unenroll # update the "unenrolled" course array in the user record on Sailthru if new enroll or unenroll
if new_enroll: if new_enroll:
......
...@@ -15,7 +15,6 @@ from ecommerce_worker.sailthru.v1.tasks import ( ...@@ -15,7 +15,6 @@ from ecommerce_worker.sailthru.v1.tasks import (
update_course_enrollment, _update_unenrolled_list, _get_course_content, _get_course_content_from_ecommerce, update_course_enrollment, _update_unenrolled_list, _get_course_content, _get_course_content_from_ecommerce,
send_course_refund_email send_course_refund_email
) )
from ecommerce_worker.sailthru.v1.utils import get_sailthru_configuration
from ecommerce_worker.utils import get_configuration from ecommerce_worker.utils import get_configuration
TEST_EMAIL = "test@edx.org" TEST_EMAIL = "test@edx.org"
...@@ -346,7 +345,8 @@ class SailthruTests(TestCase): ...@@ -346,7 +345,8 @@ class SailthruTests(TestCase):
}, },
'title': 'Course ' + self.course_id + ' mode: audit', 'title': 'Course ' + self.course_id + ' mode: audit',
'url': self.course_url, 'url': self.course_url,
'price': 100, 'qty': 1, 'price': 0,
'qty': 1,
'id': self.course_id + '-audit' 'id': self.course_id + '-audit'
}], }],
options={'send_template': 'enroll_template'}, options={'send_template': 'enroll_template'},
...@@ -354,36 +354,6 @@ class SailthruTests(TestCase): ...@@ -354,36 +354,6 @@ class SailthruTests(TestCase):
message_id='cookie_bid' message_id='cookie_bid'
) )
@patch('ecommerce_worker.sailthru.v1.tasks.get_sailthru_configuration')
@patch('ecommerce_worker.sailthru.v1.utils.SailthruClient.purchase')
@patch('ecommerce_worker.sailthru.v1.utils.SailthruClient.api_get')
@patch('ecommerce_worker.sailthru.v1.utils.SailthruClient.api_post')
def test_update_course_enroll_skip(self, mock_sailthru_api_post,
mock_sailthru_api_get, mock_sailthru_purchase,
mock_get_configuration):
"""test audit enroll with configured cost = 0"""
config = get_sailthru_configuration(None)
config['SAILTHRU_MINIMUM_COST'] = 0
mock_get_configuration.return_value = config
# create mocked Sailthru API responses
mock_sailthru_api_post.return_value = MockSailthruResponse({'ok': True})
mock_sailthru_api_get.return_value = MockSailthruResponse({'vars': {'upgrade_deadline_verified': '2020-03-12'}})
mock_sailthru_purchase.return_value = MockSailthruResponse({'ok': True})
update_course_enrollment.delay(
TEST_EMAIL,
self.course_url,
False,
'audit',
course_id=self.course_id,
currency='USD',
message_id='cookie_bid',
unit_cost=Decimal(0)
)
mock_sailthru_purchase.assert_not_called()
@patch('ecommerce_worker.sailthru.v1.tasks.logger.error') @patch('ecommerce_worker.sailthru.v1.tasks.logger.error')
@patch('ecommerce_worker.sailthru.v1.utils.SailthruClient.purchase') @patch('ecommerce_worker.sailthru.v1.utils.SailthruClient.purchase')
@patch('ecommerce_worker.sailthru.v1.utils.SailthruClient.api_get') @patch('ecommerce_worker.sailthru.v1.utils.SailthruClient.api_get')
......
Markdown is supported
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