本文整理匯總了Python中oscar.apps.shipping.methods.FixedPrice.calculate方法的典型用法代碼示例。如果您正苦於以下問題:Python FixedPrice.calculate方法的具體用法?Python FixedPrice.calculate怎麽用?Python FixedPrice.calculate使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類oscar.apps.shipping.methods.FixedPrice
的用法示例。
在下文中一共展示了FixedPrice.calculate方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: test_update_address_book
# 需要導入模塊: from oscar.apps.shipping.methods import FixedPrice [as 別名]
# 或者: from oscar.apps.shipping.methods.FixedPrice import calculate [as 別名]
def test_update_address_book(self):
basket = factories.create_basket(empty=True)
user = factories.UserFactory()
add_product(basket, D('12.00'))
shipping_method = FixedPrice(D('5.00'), D('5.00'))
billing_address = factories.BillingAddressFactory(line1='1 Boardwalk Place',
line2='Trafalgar Way',
line3='Tower Hamlets',
line4='London')
shipping_address = factories.ShippingAddressFactory(line1='Knightsbridge',
line2='159',
line4='London')
shipping_charge = shipping_method.calculate(basket)
order_total = OrderTotalCalculator().calculate(basket, shipping_charge)
order_submission_data = {'user': user,
'order_number': '12345',
'basket': basket,
'shipping_address': shipping_address,
'shipping_method': shipping_method,
'shipping_charge': shipping_charge,
'billing_address': billing_address,
'order_total': order_total}
OrderPlacementMixin().place_order(**order_submission_data)
self.assertEqual(user.addresses.filter(hash=billing_address.generate_hash()).count(), 1)
self.assertEqual(user.addresses.filter(hash=shipping_address.generate_hash()).count(), 1)
user_billing_address = user.addresses.get(hash=billing_address.generate_hash())
user_shipping_address = user.addresses.get(hash=shipping_address.generate_hash())
self.assertEqual(user_billing_address.num_orders_as_billing_address, 1)
self.assertEqual(user_shipping_address.num_orders_as_shipping_address, 1)
order_submission_data['order_number'] = '12346'
OrderPlacementMixin().place_order(**order_submission_data)
user_billing_address = user.addresses.get(hash=billing_address.generate_hash())
user_shipping_address = user.addresses.get(hash=shipping_address.generate_hash())
self.assertEqual(user_billing_address.num_orders_as_billing_address, 2)
self.assertEqual(user_shipping_address.num_orders_as_shipping_address, 2)
order_submission_data.pop('billing_address', None)
order_submission_data['order_number'] = '123457'
OrderPlacementMixin().place_order(**order_submission_data)
user_billing_address = user.addresses.get(hash=billing_address.generate_hash())
user_shipping_address = user.addresses.get(hash=shipping_address.generate_hash())
self.assertEqual(user_billing_address.num_orders_as_billing_address, 2)
self.assertEqual(user_shipping_address.num_orders_as_shipping_address, 3)
shipping_address.line2 = '160'
order_submission_data['billing_address'] = billing_address
order_submission_data['order_number'] = '123458'
OrderPlacementMixin().place_order(**order_submission_data)
user_billing_address = user.addresses.get(hash=billing_address.generate_hash())
user_shipping_address = user.addresses.get(hash=shipping_address.generate_hash())
self.assertEqual(user_billing_address.num_orders_as_billing_address, 3)
self.assertEqual(user_shipping_address.num_orders_as_shipping_address, 1)