当前位置: 首页>>代码示例>>Python>>正文


Python Order.set_shipping_address方法代码示例

本文整理汇总了Python中shop.models.ordermodel.Order.set_shipping_address方法的典型用法代码示例。如果您正苦于以下问题:Python Order.set_shipping_address方法的具体用法?Python Order.set_shipping_address怎么用?Python Order.set_shipping_address使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在shop.models.ordermodel.Order的用法示例。


在下文中一共展示了Order.set_shipping_address方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: BaseBackendTestCase

# 需要导入模块: from shop.models.ordermodel import Order [as 别名]
# 或者: from shop.models.ordermodel.Order import set_shipping_address [as 别名]
class BaseBackendTestCase(TestCase):

    def setUp(self):
        self.user = User.objects.create(
            username="test",
            email="[email protected]",
            first_name="Test",
            last_name="User")

        self.shop = PaymentAPI()
        self.backend = GenericPayerBackend(shop=self.shop)

        class Mock(object):
            pass

        self.request = Mock()
        setattr(self.request, 'user', self.user)

        self.user.save()
        self.country = Country.objects.create(name='CH')
        self.address = AddressModel()
        self.address.client = self.client
        self.address.address = 'address'
        self.address.address2 = 'address2'
        self.address.zip_code = '1234'
        self.address.state = 'ZH'
        self.address.country = self.country
        self.address.is_billing = False
        self.address.is_shipping = True
        self.address.save()

        self.address2 = AddressModel()
        self.address2.client = self.client
        self.address2.address = '2address'
        self.address2.address2 = '2address2'
        self.address2.zip_code = '21234'
        self.address2.state = '2ZH'
        self.address2.country = self.country
        self.address2.is_billing = True
        self.address2.is_shipping = False
        self.address2.save()

        # The order fixture

        self.order = Order()
        self.order.user = self.user
        self.order.order_subtotal = Decimal('100')  # One item worth 100
        self.order.order_total = Decimal('120')  # plus a test field worth 10
        self.order.status = Order.PROCESSING
        ship_address = self.address
        bill_address = self.address2

        self.order.set_shipping_address(ship_address)
        self.order.set_billing_address(bill_address)
        self.order.save()

        # Orderitems
        self.orderitem = OrderItem()
        self.orderitem.order = self.order

        self.orderitem.product_name = 'Test item'
        self.orderitem.unit_price = Decimal("100")
        self.orderitem.quantity = 1

        self.orderitem.line_subtotal = Decimal('100')
        self.orderitem.line_total = Decimal('110')
        self.orderitem.save()

        oi = OrderExtraInfo()
        oi.order = self.order
        oi.text = "buffalo " * 64
        oi.save()

        eoif = ExtraOrderItemPriceField()
        eoif.order_item = self.orderitem
        eoif.label = 'Fake extra field'
        eoif.value = Decimal("10")
        eoif.save()

        eof = ExtraOrderPriceField()
        eof.order = self.order
        eof.label = "Fake Taxes"
        eof.value = Decimal("10")
        eof.save()
开发者ID:hnejadi,项目名称:django-shop-payer-backend,代码行数:86,代码来源:tests.py

示例2: PayOnDeliveryTestCase

# 需要导入模块: from shop.models.ordermodel import Order [as 别名]
# 或者: from shop.models.ordermodel.Order import set_shipping_address [as 别名]
class PayOnDeliveryTestCase(TestCase):

    def setUp(self):
        self.user = User.objects.create(username="test",
                                        email="[email protected]",
                                        first_name="Test",
                                        last_name="Toto")
        self.user.save()
        self.country = Country.objects.create(name='CH')
        self.address = Address()
        self.address.client = self.client
        self.address.address = 'address'
        self.address.address2 = 'address2'
        self.address.zip_code = '1234'
        self.address.state = 'ZH'
        self.address.country = self.country
        self.address.is_billing = False
        self.address.is_shipping = True
        self.address.save()

        self.address2 = Address()
        self.address2.client = self.client
        self.address2.address = '2address'
        self.address2.address2 = '2address2'
        self.address2.zip_code = '21234'
        self.address2.state = '2ZH'
        self.address2.country = self.country
        self.address2.is_billing = True
        self.address2.is_shipping = False
        self.address2.save()

        # The order fixture

        self.order = Order()
        self.order.user = self.user
        self.order.order_subtotal = Decimal('100')  # One item worth 100
        self.order.order_total = Decimal('120')  # plus a test field worth 10
        self.order.status = Order.PROCESSING
        ship_address = self.address
        bill_address = self.address2

        self.order.set_shipping_address(ship_address)
        self.order.set_billing_address(bill_address)
        self.order.save()

        # Orderitems
        self.orderitem = OrderItem()
        self.orderitem.order = self.order

        self.orderitem.product_name = 'Test item'
        self.orderitem.unit_price = Decimal("100")
        self.orderitem.quantity = 1

        self.orderitem.line_subtotal = Decimal('100')
        self.orderitem.line_total = Decimal('110')
        self.orderitem.save()

        eoif = ExtraOrderItemPriceField()
        eoif.order_item = self.orderitem
        eoif.label = 'Fake extra field'
        eoif.value = Decimal("10")
        eoif.save()

        eof = ExtraOrderPriceField()
        eof.order = self.order
        eof.label = "Fake Taxes"
        eof.value = Decimal("10")
        eof.save()

    def test01_backend_returns_urls(self):
        be = PayOnDeliveryBackend(shop=PaymentAPI())
        urls = be.get_urls()
        self.assertNotEqual(urls, None)
        self.assertEqual(len(urls), 1)

    def test02_must_be_logged_in_if_setting_is_true(self):
        with SettingsOverride(SHOP_FORCE_LOGIN=True):
            resp = self.client.get(reverse('shop:pay-on-delivery'))
            self.assertEqual(resp.status_code, 302)
            self.assertTrue('accounts/login/' in resp._headers['location'][1])

    def test_order_required_before_payment(self):
        """ See issue #84 """
        # Session only (no order)
        response = self.client.get(reverse('shop:pay-on-delivery'))
        self.assertEqual(302, response.status_code)
        self.assertEqual('http://testserver/shop/cart/', response._headers['location'][1])

        # User logged in (no order)
        username = 'user'
        pw = 'pass'
        User.objects.create_user(username=username, password=pw, email='[email protected]')
        logged_in = self.client.login(username=username, password=pw)
        self.assertTrue(logged_in)
        response = self.client.get(reverse('shop:pay-on-delivery'))
        self.assertEqual(302, response.status_code)
        self.assertEqual('http://testserver/shop/cart/', response._headers['location'][1])
        self.client.logout()

        # User logged in and has order
#.........这里部分代码省略.........
开发者ID:berrym72,项目名称:django-shop,代码行数:103,代码来源:payment.py

示例3: PayOnDeliveryTestCase

# 需要导入模块: from shop.models.ordermodel import Order [as 别名]
# 或者: from shop.models.ordermodel.Order import set_shipping_address [as 别名]
class PayOnDeliveryTestCase(TestCase):

    def setUp(self):
        self.user = User.objects.create(username="test",
                                        email="[email protected]",
                                        first_name="Test",
                                        last_name="Toto")
        self.user.save()
        self.country = Country.objects.create(name='CH')
        self.address = Address()
        self.address.client = self.client
        self.address.address = 'address'
        self.address.address2 = 'address2'
        self.address.zip_code = '1234'
        self.address.state = 'ZH'
        self.address.country = self.country
        self.address.is_billing = False
        self.address.is_shipping = True
        self.address.save()

        self.address2 = Address()
        self.address2.client = self.client
        self.address2.address = '2address'
        self.address2.address2 = '2address2'
        self.address2.zip_code = '21234'
        self.address2.state = '2ZH'
        self.address2.country = self.country
        self.address2.is_billing = True
        self.address2.is_shipping = False
        self.address2.save()

        # The order fixture

        self.order = Order()
        self.order.user = self.user
        self.order.order_subtotal = Decimal('100')  # One item worth 100
        self.order.order_total = Decimal('120')  # plus a test field worth 10
        self.order.status = Order.PROCESSING
        ship_address = self.address
        bill_address = self.address2

        self.order.set_shipping_address(ship_address)
        self.order.set_billing_address(bill_address)
        self.order.save()

        # Orderitems
        self.orderitem = OrderItem()
        self.orderitem.order = self.order

        self.orderitem.product_name = 'Test item'
        self.orderitem.unit_price = Decimal("100")
        self.orderitem.quantity = 1

        self.orderitem.line_subtotal = Decimal('100')
        self.orderitem.line_total = Decimal('110')
        self.orderitem.save()

        eoif = ExtraOrderItemPriceField()
        eoif.order_item = self.orderitem
        eoif.label = 'Fake extra field'
        eoif.value = Decimal("10")
        eoif.save()

        eof = ExtraOrderPriceField()
        eof.order = self.order
        eof.label = "Fake Taxes"
        eof.value = Decimal("10")
        eof.save()

    def test01_backend_returns_urls(self):
        be = PayOnDeliveryBackend(shop=PaymentAPI())
        urls = be.get_urls()
        self.assertNotEqual(urls, None)
        self.assertEqual(len(urls), 1)

    def test02_must_be_logged_in_if_setting_is_true(self):
        with SettingsOverride(SHOP_FORCE_LOGIN=True):
            resp = self.client.get(reverse('pay-on-delivery'))
            self.assertEqual(resp.status_code, 302)
            self.assertTrue('accounts/login/' in resp._headers['location'][1])
开发者ID:Fandekasp,项目名称:django-shop,代码行数:82,代码来源:payment.py


注:本文中的shop.models.ordermodel.Order.set_shipping_address方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。