• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python ordermodel.Order类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: OrderTestCase

class OrderTestCase(TestCase):
    def setUp(self):

        self.order = Order()
        self.order.order_subtotal = Decimal("10")
        self.order.order_total = Decimal("10")
        self.order.shipping_cost = Decimal("0")

        self.order.shipping_name = "toto"
        self.order.shipping_address = "address"
        self.order.shipping_address2 = "address2"
        self.order.shipping_zip_code = "zip"
        self.order.shipping_state = "state"
        self.order.shipping_country = "country"

        self.order.billing_name = "toto"
        self.order.billing_address = "address"
        self.order.billing_address2 = "address2"
        self.order.billing_zip_code = "zip"
        self.order.billing_state = "state"
        self.order.billing_country = "country"

        self.order.save()

    def test_order_is_completed_works(self):
        ret = self.order.is_completed()
        self.assertNotEqual(ret, Order.COMPLETED)

    def test_is_payed_works(self):
        ret = self.order.is_payed()
        self.assertEqual(ret, False)
开发者ID:wmsmith,项目名称:django-shop,代码行数:31,代码来源:order.py


示例2: SignalHandlerBaseTestCase

class SignalHandlerBaseTestCase(object):
    """
    Base test case class for test classes that test signal handlers.
    """
    def setUp(self):
        self.user = User.objects.create(
                username="test",
                email="[email protected]")
        self.request = Mock()
        setattr(self.request, 'user', self.user)
        self.order = Order()
        self.order.user = self.user
        self.order.order_subtotal = decimal.Decimal('10')
        self.order.order_total = decimal.Decimal('10')
        self.order.shipping_cost = decimal.Decimal('0')

        self.order.shipping_address_text = 'shipping address example'
        self.order.billing_address_text = 'billing address example'

        self.order.save()
        self.rendered_templates = []
        template_rendered.connect(self.template_rendered_listener)

    def tearDown(self):
        template_rendered.disconnect(self.template_rendered_listener)

    def template_rendered_listener(self, **kwargs):
        self.rendered_templates.append(kwargs.get('sender'))

    def was_template_rendered(self, name):
        for template in self.rendered_templates:
            if template.name == name:
                return True
        return False
开发者ID:airtonix,项目名称:django-shop-simplenotifications,代码行数:34,代码来源:test_models.py


示例3: OrderTestCase

class OrderTestCase(TestCase):
    def create_fixtures(self):
        
        self.order = Order()
        self.order.order_subtotal = Decimal('10')
        self.order.order_total = Decimal('10')
        self.order.amount_payed = Decimal('0')
        self.order.shipping_cost = Decimal('0')
        
        self.order.shipping_name = 'toto'
        self.order.shipping_address = 'address'
        self.order.shipping_address2 = 'address2'
        self.order.shipping_zip_code = 'zip'
        self.order.shipping_state = 'state'
        self.order.shipping_country = 'country'
        
        self.order.billing_name = 'toto'
        self.order.billing_address = 'address'
        self.order.billing_address2 = 'address2'
        self.order.billing_zip_code = 'zip'
        self.order.billing_state = 'state'
        self.order.billing_country = 'country'
        
        self.order.save()
    
    def test_01_order_is_completed_works(self):
        self.create_fixtures()
        ret = self.order.is_completed()
        self.assertNotEqual(ret, Order.COMPLETED)
    
    def test_02_is_payed_works(self):
        self.create_fixtures()
        ret = self.order.is_payed()
        self.assertEqual(ret, False)
开发者ID:FinalAngel,项目名称:django-shop,代码行数:34,代码来源:order.py


示例4: ProductStatisticsTestCase

class ProductStatisticsTestCase(TestCase):

    def setUp(self):
        self.product = Product()
        self.product.name = 'test'
        self.product.unit_price = Decimal('1.0')
        self.product.save()
        
        self.product2 = Product()
        self.product2.name = 'test2'
        self.product2.unit_price = Decimal('1.0')
        self.product2.save()
        
        self.product3 = Product()
        self.product3.name = 'test3'
        self.product3.unit_price = Decimal('1.0')
        self.product3.save()

        self.order = Order()
        self.order.order_subtotal = Decimal('10')
        self.order.order_total = Decimal('10')
        self.order.shipping_cost = Decimal('0')
        
        self.order.shipping_name = 'toto'
        self.order.shipping_address = 'address'
        self.order.shipping_address2 = 'address2'
        self.order.shipping_city = 'city'
        self.order.shipping_zip_code = 'zip'
        self.order.shipping_state = 'state'
        self.order.shipping_country = 'country'
        
        self.order.billing_name = 'toto'
        self.order.billing_address = 'address'
        self.order.billing_address2 = 'address2'
        self.order.billing_city = 'city'
        self.order.billing_zip_code = 'zip'
        self.order.billing_state = 'state'
        self.order.billing_country = 'country'
        self.order.save()
        
        self.orderitem1 = OrderItem()
        self.orderitem1.order = self.order
        self.orderitem1.product = self.product
        self.orderitem1.quantity = 5 # this will be the most bought
        self.orderitem1.save()
        
        self.orderitem2 = OrderItem()
        self.orderitem2.order = self.order
        self.orderitem2.product = self.product2
        self.orderitem2.quantity = 1 # this will be the second most
        self.orderitem2.save()

    def test_top_selling_works(self):
        res = Product.statistics.top_selling_products(10)
        self.assertNotEqual(res, None)
        self.assertEqual(len(res), 2)
        self.assertTrue(self.product3 not in res)
开发者ID:ojii,项目名称:django-shop,代码行数:57,代码来源:product.py


示例5: OrderPaymentTestCase

class OrderPaymentTestCase(TestCase):
    
    def create_fixtures(self):
        self.user = User.objects.create(username="test", email="[email protected]")
        
        self.request = Mock()
        setattr(self.request, 'user', None)
        
        self.order = Order()
        self.order.order_subtotal = Decimal('10')
        self.order.order_total = Decimal('10')
        self.order.shipping_cost = Decimal('0')
        
        self.order.shipping_name = 'toto'
        self.order.shipping_address = 'address'
        self.order.shipping_address2 = 'address2'
        self.order.shipping_zip_code = 'zip'
        self.order.shipping_state = 'state'
        self.order.shipping_country = 'country'
        
        self.order.billing_name = 'toto'
        self.order.billing_address = 'address'
        self.order.billing_address2 = 'address2'
        self.order.billing_zip_code = 'zip'
        self.order.billing_state = 'state'
        self.order.billing_country = 'country'
        
        self.order.save()
    
    def test_payment_sum_works(self):
        self.create_fixtures()
        
        self.assertEqual(self.order.amount_payed, 0)
        
    def test_payment_sum_works_with_partial_payments(self):
        self.create_fixtures()
        OrderPayment.objects.create(
                order = self.order,
                amount = Decimal('2'),
                transaction_id = 'whatever',
                payment_method = 'test method'
                )
        self.assertEqual(self.order.amount_payed, 2)
        self.assertEqual(self.order.is_payed(), False)
        
    def test_payment_sum_works_with_full_payments(self):
        self.create_fixtures()
        OrderPayment.objects.create(
                order = self.order,
                amount = Decimal('10'),
                transaction_id = 'whatever',
                payment_method = 'test method'
                )
        self.assertEqual(self.order.amount_payed, 10)
        self.assertEqual(self.order.is_payed(), True)
开发者ID:matthiasnuesch,项目名称:django-shop,代码行数:55,代码来源:order.py


示例6: ShippingApiTestCase

class ShippingApiTestCase(TestCase):

    def create_fixtures(self):
        self.user = User.objects.create(username="test", email="[email protected]")

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

        self.order = Order()
        self.order.order_subtotal = Decimal('10')
        self.order.order_total = Decimal('10')
        self.order.shipping_cost = Decimal('0')

        self.order.shipping_name = 'toto'
        self.order.shipping_address = 'address'
        self.order.shipping_address2 = 'address2'
        self.order.shipping_city = 'city'
        self.order.shipping_zip_code = 'zip'
        self.order.shipping_state = 'state'
        self.order.shipping_country = 'country'

        self.order.billing_name = 'toto'
        self.order.billing_address = 'address'
        self.order.billing_address2 = 'address2'
        self.order.billing_city = 'city'
        self.order.billing_zip_code = 'zip'
        self.order.billing_state = 'state'
        self.order.billing_country = 'country'

        self.order.save()
    
        self.shipping_label = "Shipping"
        self.shipping_value = Decimal("10")

    def test_adding_shipping_costs_work(self):
        self.create_fixtures()
        api = ShippingAPI()
        api.add_shipping_costs(self.order, self.shipping_label, self.shipping_value)
        self.assertEqual(self.order.shipping_costs, self.shipping_value)
        self.assertEqual(self.order.order_total, (self.order.order_subtotal +
            self.shipping_value))
        
    def test_adding_shipping_costs_twice_works(self):
        # That should test against #39 regressions
        self.create_fixtures()
        api = ShippingAPI()
        
        api.add_shipping_costs(self.order, self.shipping_label, self.shipping_value)
        api.add_shipping_costs(self.order, self.shipping_label, self.shipping_value)
        
        self.assertEqual(self.order.shipping_costs, self.shipping_value)
        self.assertEqual(self.order.order_total, (self.order.order_subtotal +
            self.shipping_value))
开发者ID:MechanisM,项目名称:django-shop,代码行数:53,代码来源:shipping.py


示例7: setUp

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

        self.request = Mock()
        setattr(self.request, "user", None)

        self.order = Order()
        self.order.order_subtotal = Decimal("10")
        self.order.order_total = Decimal("10")
        self.order.shipping_cost = Decimal("0")

        self.order.shipping_name = "toto"
        self.order.shipping_address = "address"
        self.order.shipping_address2 = "address2"
        self.order.shipping_zip_code = "zip"
        self.order.shipping_state = "state"
        self.order.shipping_country = "country"

        self.order.billing_name = "toto"
        self.order.billing_address = "address"
        self.order.billing_address2 = "address2"
        self.order.billing_zip_code = "zip"
        self.order.billing_state = "state"
        self.order.billing_country = "country"

        self.order.save()
开发者ID:wmsmith,项目名称:django-shop,代码行数:26,代码来源:order.py


示例8: test_order_required_before_shipping_processed

    def test_order_required_before_shipping_processed(self):
        """ See issue #84 """
        # Session only (no order)
        response = self.client.get(reverse('flat_process'))
        self.assertEqual(response.status_code, 302)

        # User logged in (no order)
        view = self.backend.view_process_order(self.request)
        self.assertEqual(view.get('location', None), '/')

        # User logged in with order
        order = Order()
        setattr(order, 'user', self.user)
        order.save()
        view = self.backend.view_process_order(self.request)
        self.assertEqual(view.get('location', None), reverse('checkout_confirm'))
开发者ID:albeirochoa,项目名称:django-shop,代码行数:16,代码来源:shipping.py


示例9: setUp

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

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

        self.order = Order()
        self.order.order_subtotal = Decimal('10')
        self.order.order_total = Decimal('10')
        self.order.shipping_cost = Decimal('0')

        self.order.shipping_name = 'toto'
        self.order.shipping_address = 'address'
        self.order.shipping_address2 = 'address2'
        self.order.shipping_city = 'city'
        self.order.shipping_zip_code = 'zip'
        self.order.shipping_state = 'state'
        self.order.shipping_country = 'country'

        self.order.billing_name = 'toto'
        self.order.billing_address = 'address'
        self.order.billing_address2 = 'address2'
        self.order.billing_city = 'city'
        self.order.billing_zip_code = 'zip'
        self.order.billing_state = 'state'
        self.order.billing_country = 'country'

        self.order.save()
    
        self.shipping_label = "Shipping"
        self.shipping_value = Decimal("10")
开发者ID:RuuPiE,项目名称:django-shop,代码行数:31,代码来源:shipping.py


示例10: create_fixtures

 def create_fixtures(self):
     self.user = User.objects.create(username="test", email="[email protected]")
     
     self.request = Mock()
     setattr(self.request, 'user', None)
     
     self.order = Order()
     self.order.order_subtotal = Decimal('10')
     self.order.order_total = Decimal('10')
     self.order.amount_payed = Decimal('0')
     self.order.shipping_cost = Decimal('0')
     
     self.order.shipping_name = 'toto'
     self.order.shipping_address = 'address'
     self.order.shipping_address2 = 'address2'
     self.order.shipping_zip_code = 'zip'
     self.order.shipping_state = 'state'
     self.order.shipping_country = 'country'
     
     self.order.billing_name = 'toto'
     self.order.billing_address = 'address'
     self.order.billing_address2 = 'address2'
     self.order.billing_zip_code = 'zip'
     self.order.billing_state = 'state'
     self.order.billing_country = 'country'
     
     self.order.save()
开发者ID:FinalAngel,项目名称:django-shop,代码行数:27,代码来源:order.py


示例11: setUp

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

        self.order = Order()
        self.order.order_subtotal = Decimal('10')
        self.order.order_total = Decimal('10')
        self.order.shipping_cost = Decimal('0')

        self.address = AddressModel.objects.create(
            name="Mary-Jane Watson",
            address="Main Street 123",
            address2="c/o Someone",
            zip_code="12345",
            city="Anytown",
            state="N/A",
            user_shipping=self.user,
            user_billing=self.user,
        )

        self.order.shipping_address_text = self.address.as_text()
        self.order.billing_address_text = self.address.as_text()

        self.order.save()
开发者ID:hnejadi,项目名称:django-shop-payer-backend,代码行数:27,代码来源:tests.py


示例12: OrderPaymentTestCase

class OrderPaymentTestCase(TestCase):
    def setUp(self):
        self.user = User.objects.create(username="test", email="[email protected]")

        self.request = Mock()
        setattr(self.request, "user", None)

        self.order = Order()
        self.order.order_subtotal = Decimal("10")
        self.order.order_total = Decimal("10")
        self.order.shipping_cost = Decimal("0")

        self.order.shipping_name = "toto"
        self.order.shipping_address = "address"
        self.order.shipping_address2 = "address2"
        self.order.shipping_zip_code = "zip"
        self.order.shipping_state = "state"
        self.order.shipping_country = "country"

        self.order.billing_name = "toto"
        self.order.billing_address = "address"
        self.order.billing_address2 = "address2"
        self.order.billing_zip_code = "zip"
        self.order.billing_state = "state"
        self.order.billing_country = "country"

        self.order.save()

    def test_payment_sum_works(self):
        self.assertEqual(self.order.amount_payed, Decimal("-1"))

    def test_payment_sum_works_with_partial_payments(self):
        OrderPayment.objects.create(
            order=self.order, amount=Decimal("2"), transaction_id="whatever", payment_method="test method"
        )
        self.assertEqual(self.order.amount_payed, 2)
        self.assertEqual(self.order.is_payed(), False)

    def test_payment_sum_works_with_full_payments(self):
        OrderPayment.objects.create(
            order=self.order, amount=Decimal("10"), transaction_id="whatever", payment_method="test method"
        )
        self.assertEqual(self.order.amount_payed, 10)
        self.assertEqual(self.order.is_payed(), True)
开发者ID:wmsmith,项目名称:django-shop,代码行数:44,代码来源:order.py


示例13: ShippingApiTestCase

class ShippingApiTestCase(TestCase):

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

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

        self.order = Order()
        self.order.order_subtotal = Decimal('10')
        self.order.order_total = Decimal('10')
        self.order.shipping_cost = Decimal('0')

        self.order.shipping_address_text = 'shipping address example'
        self.order.billing_address_text = 'billing address example'

        self.order.save()

        self.shipping_label = "Shipping"
        self.shipping_value = Decimal("10")

    def test_adding_shipping_costs_work(self):
        api = ShippingAPI()
        api.add_shipping_costs(self.order, self.shipping_label,
            self.shipping_value)
        self.assertEqual(self.order.shipping_costs, self.shipping_value)
        self.assertEqual(self.order.order_total, (self.order.order_subtotal +
            self.shipping_value))

    def test_adding_shipping_costs_twice_works(self):
        # That should test against #39 regressions
        api = ShippingAPI()

        api.add_shipping_costs(self.order, self.shipping_label,
            self.shipping_value)
        api.add_shipping_costs(self.order, self.shipping_label,
            self.shipping_value)

        self.assertEqual(self.order.shipping_costs, self.shipping_value)
        self.assertEqual(self.order.order_total, (self.order.order_subtotal +
            self.shipping_value))
开发者ID:albeirochoa,项目名称:django-shop,代码行数:42,代码来源:shipping.py


示例14: OrderTestCase

class OrderTestCase(TestCase):
    def setUp(self):
        
        self.order = Order()
        self.order.order_subtotal = Decimal('10')
        self.order.order_total = Decimal('10')
        self.order.shipping_cost = Decimal('0')
        
        self.order.shipping_address_text = 'shipping address example'
        self.order.billing_address_text = 'billing address example'
        
        self.order.save()
    
    def test_order_is_completed_works(self):
        ret = self.order.is_completed()
        self.assertNotEqual(ret, Order.COMPLETED)
    
    def test_is_payed_works(self):
        ret = self.order.is_payed()
        self.assertEqual(ret, False)
开发者ID:IAbuElRuzz,项目名称:django-shop,代码行数:20,代码来源:order.py


示例15: setUp

    def setUp(self):

        self.order = Order()
        self.order.order_subtotal = Decimal('10')
        self.order.order_total = Decimal('10')
        self.order.shipping_cost = Decimal('0')

        self.order.shipping_address_text = 'shipping address example'
        self.order.billing_address_text = 'billing address example'

        self.order.save()
开发者ID:bakanov,项目名称:django-shop,代码行数:11,代码来源:order.py


示例16: OrderPaymentTestCase

class OrderPaymentTestCase(TestCase):
    
    def setUp(self):
        self.user = User.objects.create(username="test", email="[email protected]")
        
        self.request = Mock()
        setattr(self.request, 'user', None)
        
        self.order = Order()
        self.order.order_subtotal = Decimal('10')
        self.order.order_total = Decimal('10')
        self.order.shipping_cost = Decimal('0')
        
        self.order.shipping_address_text = 'shipping address example'
        self.order.billing_address_text = 'billing address example'
        
        self.order.save()
    
    def test_payment_sum_works(self):
        self.assertEqual(self.order.amount_payed, Decimal('-1'))
        
    def test_payment_sum_works_with_partial_payments(self):
        OrderPayment.objects.create(
                order = self.order,
                amount = Decimal('2'),
                transaction_id = 'whatever',
                payment_method = 'test method'
                )
        self.assertEqual(self.order.amount_payed, 2)
        self.assertEqual(self.order.is_payed(), False)
        
    def test_payment_sum_works_with_full_payments(self):
        OrderPayment.objects.create(
                order = self.order,
                amount = Decimal('10'),
                transaction_id = 'whatever',
                payment_method = 'test method'
                )
        self.assertEqual(self.order.amount_payed, 10)
        self.assertEqual(self.order.is_payed(), True)
开发者ID:IAbuElRuzz,项目名称:django-shop,代码行数:40,代码来源:order.py


示例17: setUp

    def setUp(self):
        self.product = Product()
        self.product.name = 'test'
        self.product.unit_price = Decimal('1.0')
        self.product.save()
        
        self.product2 = Product()
        self.product2.name = 'test2'
        self.product2.unit_price = Decimal('1.0')
        self.product2.save()
        
        self.product3 = Product()
        self.product3.name = 'test3'
        self.product3.unit_price = Decimal('1.0')
        self.product3.save()

        self.order = Order()
        self.order.order_subtotal = Decimal('10')
        self.order.order_total = Decimal('10')
        self.order.shipping_cost = Decimal('0')
        
        self.order.shipping_name = 'toto'
        self.order.shipping_address = 'address'
        self.order.shipping_address2 = 'address2'
        self.order.shipping_city = 'city'
        self.order.shipping_zip_code = 'zip'
        self.order.shipping_state = 'state'
        self.order.shipping_country = 'country'
        
        self.order.billing_name = 'toto'
        self.order.billing_address = 'address'
        self.order.billing_address2 = 'address2'
        self.order.billing_city = 'city'
        self.order.billing_zip_code = 'zip'
        self.order.billing_state = 'state'
        self.order.billing_country = 'country'
        self.order.save()
        
        self.orderitem1 = OrderItem()
        self.orderitem1.order = self.order
        self.orderitem1.product = self.product
        self.orderitem1.quantity = 5 # this will be the most bought
        self.orderitem1.save()
        
        self.orderitem2 = OrderItem()
        self.orderitem2.order = self.order
        self.orderitem2.product = self.product2
        self.orderitem2.quantity = 1 # this will be the second most
        self.orderitem2.save()
开发者ID:ojii,项目名称:django-shop,代码行数:49,代码来源:product.py


示例18: setUp

 def setUp(self):
     self.user = User.objects.create(username="test", email="[email protected]")
     
     self.request = Mock()
     setattr(self.request, 'user', None)
     
     self.order = Order()
     self.order.order_subtotal = Decimal('10')
     self.order.order_total = Decimal('10')
     self.order.shipping_cost = Decimal('0')
     
     self.order.shipping_address_text = 'shipping address example'
     self.order.billing_address_text = 'billing address example'
     
     self.order.save()
开发者ID:IAbuElRuzz,项目名称:django-shop,代码行数:15,代码来源:order.py


示例19: setUp

    def setUp(self):
        self.user = User.objects.create(username='test',
                                        email='[email protected]',
                                        first_name='Test',
                                        last_name='Toto')
        backends_pool.use_cache = False

        self.order = Order()
        self.order.order_subtotal = Decimal('10')
        self.order.order_total = Decimal('10')
        self.order.shipping_cost = Decimal('0')

        self.order.shipping_address_text = 'shipping address example'
        self.order.billing_address_text = 'billing address example'

        self.order.save()
开发者ID:albeirochoa,项目名称:django-shop,代码行数:16,代码来源:shipping.py


示例20: setUp

    def setUp(self):
        self.user = User.objects.create(
                username="test",
                email="[email protected]")
        self.request = Mock()
        setattr(self.request, 'user', self.user)
        self.order = Order()
        self.order.user = self.user
        self.order.order_subtotal = decimal.Decimal('10')
        self.order.order_total = decimal.Decimal('10')
        self.order.shipping_cost = decimal.Decimal('0')

        self.order.shipping_address_text = 'shipping address example'
        self.order.billing_address_text = 'billing address example'

        self.order.save()
        self.rendered_templates = []
        template_rendered.connect(self.template_rendered_listener)
开发者ID:airtonix,项目名称:django-shop-simplenotifications,代码行数:18,代码来源:test_models.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python ordermodel.OrderItem类代码示例发布时间:2022-05-27
下一篇:
Python cartmodel.Cart类代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap