本文整理汇总了Python中shoppingcart.models.Donation.add_to_order方法的典型用法代码示例。如果您正苦于以下问题:Python Donation.add_to_order方法的具体用法?Python Donation.add_to_order怎么用?Python Donation.add_to_order使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类shoppingcart.models.Donation
的用法示例。
在下文中一共展示了Donation.add_to_order方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_confirmation_email
# 需要导入模块: from shoppingcart.models import Donation [as 别名]
# 或者: from shoppingcart.models.Donation import add_to_order [as 别名]
def test_confirmation_email(self):
# Pay for a donation
Donation.add_to_order(self.cart, self.COST)
self.cart.start_purchase()
self.cart.purchase()
# Check that the tax-deduction information appears in the confirmation email
self.assertEqual(len(mail.outbox), 1)
email = mail.outbox[0]
self.assertEquals('Order Payment Confirmation', email.subject)
self.assertIn("tax purposes", email.body)
示例2: test_donate_to_org
# 需要导入模块: from shoppingcart.models import Donation [as 别名]
# 或者: from shoppingcart.models.Donation import add_to_order [as 别名]
def test_donate_to_org(self):
# No course ID provided, so this is a donation to the entire organization
donation = Donation.add_to_order(self.cart, self.COST)
self._assert_donation(
donation,
donation_type="general",
unit_cost=self.COST,
line_desc="Donation for edX"
)
示例3: test_donate_to_course
# 需要导入模块: from shoppingcart.models import Donation [as 别名]
# 或者: from shoppingcart.models.Donation import add_to_order [as 别名]
def test_donate_to_course(self):
# Create a test course
course = CourseFactory.create(display_name="Test Course")
# Donate to the course
donation = Donation.add_to_order(self.cart, self.COST, course_id=course.id)
self._assert_donation(
donation,
donation_type="course",
course_id=course.id,
unit_cost=self.COST,
line_desc=u"Donation for Test Course"
)
示例4: test_donate_no_such_course
# 需要导入模块: from shoppingcart.models import Donation [as 别名]
# 或者: from shoppingcart.models.Donation import add_to_order [as 别名]
def test_donate_no_such_course(self):
fake_course_id = CourseLocator(org="edx", course="fake", run="course")
with self.assertRaises(CourseDoesNotExistException):
Donation.add_to_order(self.cart, self.COST, course_id=fake_course_id)
示例5: setUp
# 需要导入模块: from shoppingcart.models import Donation [as 别名]
# 或者: from shoppingcart.models.Donation import add_to_order [as 别名]
def setUp(self):
super(TestOrderHistoryOnSiteDashboard, self).setUp()
patcher = patch('student.models.tracker')
self.mock_tracker = patcher.start()
self.user = UserFactory.create()
self.user.set_password('password')
self.user.save()
self.addCleanup(patcher.stop)
# First Order with our (fakeX) site's course.
course1 = CourseFactory.create(org='fakeX', number='999', display_name='fakeX Course')
course1_key = course1.id
course1_mode = CourseMode(course_id=course1_key,
mode_slug="honor",
mode_display_name="honor cert",
min_price=20)
course1_mode.save()
cart = Order.get_cart_for_user(self.user)
PaidCourseRegistration.add_to_order(cart, course1_key)
cart.purchase(first='FirstNameTesting123', street1='StreetTesting123')
self.fakex_site_order_id = cart.id
# Second Order with another(fooX) site's course
course2 = CourseFactory.create(org='fooX', number='888', display_name='fooX Course')
course2_key = course2.id
course2_mode = CourseMode(course_id=course2.id,
mode_slug="honor",
mode_display_name="honor cert",
min_price=20)
course2_mode.save()
cart = Order.get_cart_for_user(self.user)
PaidCourseRegistration.add_to_order(cart, course2_key)
cart.purchase(first='FirstNameTesting123', street1='StreetTesting123')
self.foox_site_order_id = cart.id
# Third Order with course not attributed to any site.
course3 = CourseFactory.create(org='fakeOtherX', number='777', display_name='fakeOtherX Course')
course3_key = course3.id
course3_mode = CourseMode(course_id=course3.id,
mode_slug="honor",
mode_display_name="honor cert",
min_price=20)
course3_mode.save()
cart = Order.get_cart_for_user(self.user)
PaidCourseRegistration.add_to_order(cart, course3_key)
cart.purchase(first='FirstNameTesting123', street1='StreetTesting123')
self.order_id = cart.id
# Fourth Order with course not attributed to any site but with a CertificateItem
course4 = CourseFactory.create(org='fakeOtherX', number='888')
course4_key = course4.id
course4_mode = CourseMode(course_id=course4.id,
mode_slug="verified",
mode_display_name="verified cert",
min_price=20)
course4_mode.save()
cart = Order.get_cart_for_user(self.user)
CertificateItem.add_to_order(cart, course4_key, 20.0, 'verified')
cart.purchase(first='FirstNameTesting123', street1='StreetTesting123')
self.certificate_order_id = cart.id
# Fifth Order with course not attributed to any site but with a Donation
course5 = CourseFactory.create(org='fakeOtherX', number='999')
course5_key = course5.id
cart = Order.get_cart_for_user(self.user)
Donation.add_to_order(cart, 20.0, course5_key)
cart.purchase(first='FirstNameTesting123', street1='StreetTesting123')
self.donation_order_id = cart.id
# also add a donation not associated with a course to make sure the None case works OK
Donation.add_to_order(cart, 10.0, None)
cart.purchase(first='FirstNameTesting123', street1='StreetTesting123')
self.courseless_donation_order_id = cart.id