本文整理汇总了Python中shop.views.checkout.CheckoutSelectionView类的典型用法代码示例。如果您正苦于以下问题:Python CheckoutSelectionView类的具体用法?Python CheckoutSelectionView怎么用?Python CheckoutSelectionView使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CheckoutSelectionView类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_shipping_address_form_post
def test_shipping_address_form_post(self):
setattr(self.request, "method", "POST")
setattr(self.request, "POST", {})
view = CheckoutSelectionView(request=self.request)
res = view.get_shipping_address_form()
self.assertNotEqual(res, None)
示例2: test_billing_address_form_post
def test_billing_address_form_post(self):
setattr(self.request, 'method', 'POST')
setattr(self.request, 'POST', {})
view = CheckoutSelectionView(request=self.request)
res = view.get_billing_address_form()
self.assertNotEqual(res, None)
示例3: test_get_context_data
def test_get_context_data(self):
setattr(self.request, 'method', 'GET')
view = CheckoutSelectionView(request=self.request)
ctx = view.get_context_data()
self.assertNotEqual(ctx, None)
self.assertNotEqual(ctx['shipping_address'], None)
self.assertNotEqual(ctx['billing_address'], None)
self.assertNotEqual(ctx['billing_shipping_form'], None)
示例4: test_billing_address_form_user_no_preset
def test_billing_address_form_user_no_preset(self):
setattr(self.request, 'user', self.user)
address = Address.objects.create(country=self.country, user_billing=self.user)
address.save()
view = CheckoutSelectionView(request=self.request)
res = view.get_billing_address_form()
self.assertEqual(res.instance, address)
示例5: test_billing_address_cache
def test_billing_address_cache(self):
setattr(self.request, "method", "POST")
setattr(self.request, "POST", {})
view = CheckoutSelectionView(request=self.request)
res = view.get_billing_address_form()
self.assertNotEqual(res, None)
res2 = view.get_billing_address_form()
self.assertEqual(res, res2)
示例6: test_shipping_address_cache
def test_shipping_address_cache(self):
setattr(self.request, 'method', 'POST')
setattr(self.request, 'POST', {})
view = CheckoutSelectionView(request=self.request)
res = view.get_shipping_address_form()
self.assertNotEqual(res, None)
res2 = view.get_shipping_address_form()
self.assertEqual(res, res2)
示例7: test_order_added_to_session_if_no_user
def test_order_added_to_session_if_no_user(self):
"""
Check that the order_id is saved on the session if
no user is available.
"""
setattr(self.request, 'user', None)
self.request.session["cart_id"] = self.cart.pk
view = CheckoutSelectionView(request=self.request)
order = view.create_order_object_from_cart()
self.assertEquals(self.request.session.get("order_id"), order.pk)
setattr(self.request, 'user', self.user)
示例8: test_processing_signal
def test_processing_signal(self):
view = CheckoutSelectionView(request=self.request)
order_from_signal = []
def receiver(sender, order=None, **kwargs):
order_from_signal.append(order)
processing.connect(receiver)
res = view.create_order_object_from_cart()
self.assertIs(res, order_from_signal[0])
示例9: test_assigning_to_order_from_view_works_with_name_and_address
def test_assigning_to_order_from_view_works_with_name_and_address(self):
self.s_add.name = 'toto'
self.s_add.address2 = 'address2'
self.s_add.save()
self.b_add.name = 'toto'
self.b_add.address2 = 'address2'
self.b_add.save()
view = CheckoutSelectionView(request=self.request)
view.save_addresses_to_order(self.order, self.s_add, self.b_add)
self.check_order_address()
示例10: test_orders_are_created_and_cleaned_up
def test_orders_are_created_and_cleaned_up(self):
view = CheckoutSelectionView(request=self.request)
# create a new order with pk 1
old_order = view.create_order_object_from_cart()
# create order with pk 2 so sqlite doesn't reuse pk 1
Order.objects.create()
# then create a different new order, from a different cart with pk 3
# order pk 1 should be deleted here
self.cart.add_product(self.product)
new_order = view.create_order_object_from_cart()
self.assertFalse(Order.objects.filter(pk=old_order.pk).exists()) # check it was deleted
self.assertNotEqual(old_order.order_total, new_order.order_total)
示例11: test_save_extra_info_to_order
def test_save_extra_info_to_order(self):
"""
Check that extra info associated with the order is saved.
"""
# Set the request to a POST and add data for the form to parse.
setattr(self.request, 'method', 'POST')
setattr(self.request, 'POST', {"text": "blah blah"})
view = CheckoutSelectionView(request=self.request)
form = view.get_extra_info_form()
self.assertTrue(form.is_valid())
order = view.create_order_object_from_cart()
view.save_extra_info_to_order(order, form)
self.assertTrue(OrderExtraInfo.objects.filter(order=order).exists())
# Set the request back to how it was in setUp()
setattr(self.request, 'method', 'GET')
del self.request.POST
示例12: test_billing_and_shipping_selection_get
def test_billing_and_shipping_selection_get(self):
view = CheckoutSelectionView(request=self.request)
res = view.get_billing_and_shipping_selection_form()
self.assertNotEqual(res, None)
示例13: url
# Cart
url(r'^cart/delete/$', CartDetails.as_view(action='delete'), # DELETE
name='cart_delete'),
url('^cart/item/$', CartDetails.as_view(action='post'), # POST
name='cart_item_add' ),
url(r'^cart/$', CartDetails.as_view(), name='cart'), # GET
url(r'^cart/update/$', CartDetails.as_view(action='put'),
name='cart_update'),
# CartItems
url('^cart/item/(?P<id>[0-9A-Za-z-_.//]+)$', CartItemDetail.as_view(),
name='cart_item' ),
# Checkout
url(r'^checkout/$', CheckoutSelectionView.as_view(),
name='checkout_selection' # First step of the checkout process
),
#url(r'^checkout/ship/$', SelectShippingView.as_view(),
# name='checkout_shipping' # First step of the checkout process
# ),
url(r'^checkout/ship/$', ShippingBackendRedirectView.as_view(),
name='checkout_shipping' # First step of the checkout process
),
#url(r'^checkout/pay/$', SelectPaymentView.as_view(),
# name='checkout_payment' # Second step of the checkout process
# ),
url(r'^checkout/pay/$', PaymentBackendRedirectView.as_view(),
name='checkout_payment' # First step of the checkout process
),
url(r'^checkout/thank_you/$', ThankYouView.as_view(),
示例14: test_order_created
def test_order_created(self):
view = CheckoutSelectionView(request=self.request)
res = view.create_order_object_from_cart()
self.assertEqual(res.order_total, Decimal('0'))
示例15: import
from django.conf.urls import patterns, url
from shop.util.decorators import cart_required
from shop.views.checkout import (
CheckoutSelectionView,
PaymentBackendRedirectView,
ShippingBackendRedirectView,
OrderConfirmView,
ThankYouView,
)
urlpatterns = patterns('',
url(r'^$', cart_required(CheckoutSelectionView.as_view()),
name='checkout_selection' # first step of the checkout process
),
url(r'^ship/$', ShippingBackendRedirectView.as_view(),
name='checkout_shipping' # second step of the checkout process
),
url(r'^confirm/$', OrderConfirmView.as_view(),
name='checkout_confirm' # third step of the checkout process
),
url(r'^pay/$', PaymentBackendRedirectView.as_view(),
name='checkout_payment' # fourth step of the checkout process
),
url(r'^thank_you/$', ThankYouView.as_view(),
name='thank_you_for_your_order' # final step of the checkout process
),
)