本文整理汇总了Python中oscar.test.newfactories.BasketFactory.add_product方法的典型用法代码示例。如果您正苦于以下问题:Python BasketFactory.add_product方法的具体用法?Python BasketFactory.add_product怎么用?Python BasketFactory.add_product使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类oscar.test.newfactories.BasketFactory
的用法示例。
在下文中一共展示了BasketFactory.add_product方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_non_free_basket_order
# 需要导入模块: from oscar.test.newfactories import BasketFactory [as 别名]
# 或者: from oscar.test.newfactories.BasketFactory import add_product [as 别名]
def test_non_free_basket_order(self, __):
""" Verify an error is raised for non-free basket. """
basket = BasketFactory(owner=self.user, site=self.site)
basket.add_product(ProductFactory(stockrecords__price_excl_tax=10))
with self.assertRaises(BasketNotFreeError):
EdxOrderPlacementMixin().place_free_order(basket)
示例2: setUp
# 需要导入模块: from oscar.test.newfactories import BasketFactory [as 别名]
# 或者: from oscar.test.newfactories.BasketFactory import add_product [as 别名]
def setUp(self):
super(CouponFulfillmentModuleTest, self).setUp()
coupon = self.create_coupon()
user = UserFactory()
basket = BasketFactory()
basket.add_product(coupon, 1)
self.order = factories.create_order(number=1, basket=basket, user=user)
示例3: _create_order
# 需要导入模块: from oscar.test.newfactories import BasketFactory [as 别名]
# 或者: from oscar.test.newfactories.BasketFactory import add_product [as 别名]
def _create_order(self, price):
seat = self.course.create_or_update_seat('verified', False, price, self.partner, None)
basket = BasketFactory()
basket.add_product(seat, 1)
order = create_order(number=1, basket=basket, user=self.user)
order.total_excl_tax = price
return seat, order
示例4: test_place_free_order
# 需要导入模块: from oscar.test.newfactories import BasketFactory [as 别名]
# 或者: from oscar.test.newfactories.BasketFactory import add_product [as 别名]
def test_place_free_order(self, __):
""" Verify an order is placed and the basket is submitted. """
basket = BasketFactory(owner=self.user, site=self.site)
basket.add_product(ProductFactory(stockrecords__price_excl_tax=0))
order = EdxOrderPlacementMixin().place_free_order(basket)
self.assertIsNotNone(order)
self.assertEqual(basket.status, Basket.SUBMITTED)
示例5: setUp
# 需要导入模块: from oscar.test.newfactories import BasketFactory [as 别名]
# 或者: from oscar.test.newfactories.BasketFactory import add_product [as 别名]
def setUp(self):
super(EnrollmentFulfillmentTestMixin, self).setUp()
user = UserFactory()
course = Course.objects.create(id=self.course_id, name='Demo Course')
self.seat = course.create_or_update_seat(self.certificate_type, False, 100, self.provider)
basket = BasketFactory()
basket.add_product(self.seat, 1)
self.order = factories.create_order(number=1, basket=basket, user=user)
示例6: setUp
# 需要导入模块: from oscar.test.newfactories import BasketFactory [as 别名]
# 或者: from oscar.test.newfactories.BasketFactory import add_product [as 别名]
def setUp(self):
super(EnrollmentCodeFulfillmentModuleTests, self).setUp()
toggle_switch(ENROLLMENT_CODE_SWITCH, True)
course = CourseFactory()
course.create_or_update_seat('verified', True, 50, self.partner)
enrollment_code = Product.objects.get(product_class__name=ENROLLMENT_CODE_PRODUCT_CLASS_NAME)
user = UserFactory()
basket = BasketFactory()
basket.add_product(enrollment_code, self.QUANTITY)
self.order = factories.create_order(number=1, basket=basket, user=user)
示例7: test_unsupported_product_class
# 需要导入模块: from oscar.test.newfactories import BasketFactory [as 别名]
# 或者: from oscar.test.newfactories.BasketFactory import add_product [as 别名]
def test_unsupported_product_class(self, mock_log_error, mock_update_course_enrollment):
""" Verify Sailthru is not contacted for non-seat products. """
coupon = self.create_coupon()
basket = BasketFactory()
basket.add_product(coupon, 1)
process_basket_addition(None, request=self.request,
user=self.user,
product=coupon, basket=basket)
self.assertFalse(mock_update_course_enrollment.called)
self.assertFalse(mock_log_error.called)
order = create_order(number=1, basket=basket, user=self.user)
process_checkout_complete(None, order=order, request=None)
self.assertFalse(mock_update_course_enrollment.called)
self.assertFalse(mock_log_error.called)
示例8: test_post_checkout_callback
# 需要导入模块: from oscar.test.newfactories import BasketFactory [as 别名]
# 或者: from oscar.test.newfactories.BasketFactory import add_product [as 别名]
def test_post_checkout_callback(self):
"""
When the post_checkout signal is emitted, the receiver should attempt
to fulfill the newly-placed order and send receipt email.
"""
httpretty.register_uri(
httpretty.GET, get_lms_url('api/credit/v1/providers/ASU'),
body='{"display_name": "Hogwarts"}',
content_type="application/json"
)
toggle_switch('ENABLE_NOTIFICATIONS', True)
course = Course.objects.create(id='edX/DemoX/Demo_Course', name='Demo Course')
seat = course.create_or_update_seat('credit', False, 50, self.partner, 'ASU', None, 2)
basket = BasketFactory()
basket.add_product(seat, 1)
order = factories.create_order(number=1, basket=basket, user=self.user)
with mock.patch('threadlocals.threadlocals.get_current_request') as mock_gcr:
mock_gcr.return_value = self.request
send_course_purchase_email(None, order=order)
self.assertEqual(len(mail.outbox), 1)
self.assertEqual(mail.outbox[0].from_email, self.site_configuration.from_email)
self.assertEqual(mail.outbox[0].subject, 'Order Receipt')
self.assertEqual(
mail.outbox[0].body,
'\nPayment confirmation for: {course_title}'
'\n\nDear {full_name},'
'\n\nThank you for purchasing {credit_hours} credit hours from {credit_provider} for {course_title}. '
'A charge will appear on your credit or debit card statement with a company name of "{platform_name}".'
'\n\nTo receive your course credit, you must also request credit at the {credit_provider} website. '
'For a link to request credit from {credit_provider}, or to see the status of your credit request, '
'go to your {platform_name} dashboard.'
'\n\nTo explore other credit-eligible courses, visit the {platform_name} website. '
'We add new courses frequently!'
'\n\nTo view your payment information, visit the following website.'
'\n{receipt_url}'
'\n\nThank you. We hope you enjoyed your course!'
'\nThe {platform_name} team'
'\n\nYou received this message because you purchased credit hours for {course_title}, '
'an {platform_name} course.\n'.format(
course_title=order.lines.first().product.title,
full_name=self.user.get_full_name(),
credit_hours=2,
credit_provider='Hogwarts',
platform_name=get_current_request().site.name,
receipt_url=get_lms_url('{}?orderNum={}'.format(settings.RECEIPT_PAGE_PATH, order.number))
)
)
示例9: create_seat_and_order
# 需要导入模块: from oscar.test.newfactories import BasketFactory [as 别名]
# 或者: from oscar.test.newfactories.BasketFactory import add_product [as 别名]
def create_seat_and_order(self, certificate_type='test-certificate-type', provider=None):
""" Create the certificate of given type and seat of given provider.
Arguments:
certificate_type(str): The type of certificate
provider(str): The provider ID.
Returns:
None
"""
self.certificate_type = certificate_type
self.provider = provider
self.seat = self.course.create_or_update_seat(self.certificate_type, False, 100, self.partner, self.provider)
basket = BasketFactory()
basket.add_product(self.seat, 1)
self.order = factories.create_order(number=2, basket=basket, user=self.user)
示例10: prepare_order
# 需要导入模块: from oscar.test.newfactories import BasketFactory [as 别名]
# 或者: from oscar.test.newfactories.BasketFactory import add_product [as 别名]
def prepare_order(self, seat_type, credit_provider_id=None):
"""
Prepares order for a post-checkout test.
Args:
seat_type (str): Course seat type
credit_provider_id (str): Credit provider associated with the course seat.
Returns:
Order
"""
course = CourseFactory()
seat = course.create_or_update_seat(seat_type, False, 50, self.partner, credit_provider_id, None, 2)
basket = BasketFactory(site=self.site)
basket.add_product(seat, 1)
order = factories.create_order(basket=basket, user=self.user)
return order
示例11: create_order
# 需要导入模块: from oscar.test.newfactories import BasketFactory [as 别名]
# 或者: from oscar.test.newfactories.BasketFactory import add_product [as 别名]
def create_order(self, user=None, credit=False, multiple_lines=False, free=False, status=ORDER.COMPLETE):
user = user or self.user
basket = BasketFactory(owner=user)
if credit:
basket.add_product(self.credit_product)
elif multiple_lines:
basket.add_product(self.verified_product)
basket.add_product(self.honor_product)
elif free:
basket.add_product(self.honor_product)
else:
basket.add_product(self.verified_product)
order = create_order(basket=basket, user=user)
order.status = status
order.save()
return order
示例12: test_post_checkout_callback
# 需要导入模块: from oscar.test.newfactories import BasketFactory [as 别名]
# 或者: from oscar.test.newfactories.BasketFactory import add_product [as 别名]
def test_post_checkout_callback(self):
"""
When the post_checkout signal is emitted, the receiver should attempt
to fulfill the newly-placed order and send receipt email.
"""
httpretty.register_uri(
httpretty.GET, get_lms_url('api/credit/v1/providers/ASU'),
body='{"display_name": "Hogwarts"}',
content_type="application/json"
)
toggle_switch('ENABLE_NOTIFICATIONS', True)
user = UserFactory()
course = Course.objects.create(id='edX/DemoX/Demo_Course', name='Demo Course')
partner = self.create_partner('edx')
seat = course.create_or_update_seat('credit', False, 50, partner, 'ASU', None, 2)
basket = BasketFactory()
basket.add_product(seat, 1)
order = factories.create_order(number=1, basket=basket, user=user)
send_course_purchase_email(None, order=order)
self.assertEqual(len(mail.outbox), 1)
self.assertEqual(mail.outbox[0].subject, 'Order Receipt')
self.assertEqual(
mail.outbox[0].body,
'\nReceipt Confirmation for: {course_name}'
'\n\nHi {full_name},\n\n'
'Thank you for purchasing {credit_hour} credit hours from {provider_name} for {course_name}.'
' The charge below will appear on your next credit or debit card statement with a '
'company name of {platform_name}.\n\nYou can see the status the status of your credit request or '
'complete the credit request process on your {platform_name} dashboard\nTo browse other '
'credit-eligible courses visit the edX website. More courses are added all the time.\n\n'
'Thank you and congratulation on your achievement. We hope you enjoy the course!\n\n'
'To view receipt please visit the link below'
'\n\n{receipt_url}\n\n'
'{platform_name} team\n\nThe edX team\n'.format(
course_name=order.lines.first().product.title,
full_name=user.get_full_name(),
credit_hour=2,
provider_name='Hogwarts',
platform_name=settings.PLATFORM_NAME,
receipt_url=get_lms_url('/commerce/checkout/receipt/?basket_id={}'.format(order.basket.id))
)
)
示例13: test_prof_ed_stale_product_removal_with_orders
# 需要导入模块: from oscar.test.newfactories import BasketFactory [as 别名]
# 或者: from oscar.test.newfactories.BasketFactory import add_product [as 别名]
def test_prof_ed_stale_product_removal_with_orders(self):
"""
Verify that professional education seats are never deleted if they have been purchased.
"""
user = self.create_user()
course = CourseFactory()
professional_product_no_verification = course.create_or_update_seat('professional', False, 0, self.partner)
self.assertEqual(course.products.count(), 2)
basket = BasketFactory(owner=user)
basket.add_product(professional_product_no_verification)
create_order(basket=basket, user=user)
course.create_or_update_seat('professional', True, 0, self.partner)
self.assertEqual(course.products.count(), 3)
product_mode = course.products.all()[0]
self.assertEqual(product_mode.attr.id_verification_required, True)
self.assertEqual(product_mode.attr.certificate_type, 'professional')
product_mode = course.products.all()[1]
self.assertEqual(product_mode.attr.id_verification_required, False)
self.assertEqual(product_mode.attr.certificate_type, 'professional')