本文整理汇总了Python中shop.models.ordermodel.Order类的典型用法代码示例。如果您正苦于以下问题:Python Order类的具体用法?Python Order怎么用?Python Order使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Order类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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)
示例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
示例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)
示例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)
示例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)
示例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))
示例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()
示例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'))
示例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")
示例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()
示例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()
示例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)
示例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))
示例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)
示例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()