def test_price_equals_transitivity(self):
     prices = (
         Price(currency='EUR', excl_tax=D('10.00'), tax=D('2.00')),
         Price(currency='USD', excl_tax=D('10.00'), tax=D('2.00')),
         Price(currency='USD', excl_tax=D('10.00'), incl_tax=D('12.00')),
         Price(currency='USD', excl_tax=D('10.00'), tax=D('8.00'))
     )
     prices_product = product(prices, prices)
     for price1, price2 in prices_product:
         self.assertEqual(price1 == price2, price2 == price1)
示例#2
0
 def _get_order_total(self):
     """
     Return the order_total in preparation for call to process_totals.
     See https://github.com/django-oscar/django-oscar/blob/1.5.4/src/oscar/apps/basket/views.py#L92-L132
     for reference in how this is calculated by django-oscar.
     """
     shipping_charge = Price('USD', excl_tax=Decimal(0), tax=Decimal(0))
     return OrderTotalCalculator().calculate(self.request.basket, shipping_charge)
示例#3
0
    def _get_order_total(self, context):
        """
        Add the order total to the context in preparation for the get_basket_context_data call.

        Note: We only calculate what we need.  This result is required before calling the shared
        ``get_basket_context_data(context)`` call.

        See https://github.com/django-oscar/django-oscar/blob/1.5.4/src/oscar/apps/basket/views.py#L92-L132
        """
        shipping_charge = Price('USD', Decimal(0))
        context['order_total'] = OrderTotalCalculator().calculate(
            self.request.basket, shipping_charge)
        return context
示例#4
0
 def test_can_have_tax_set_later(self):
     price = Price('USD', D('10.00'))
     price.tax = D('2.00')
     self.assertEqual(D('12.00'), price.incl_tax)
示例#5
0
 def test_can_be_instantiated_with_tax_amount(self):
     price = Price('USD', D('10.00'), tax=D('2.00'))
     self.assertTrue(price.is_tax_known)
     self.assertEqual(D('12.00'), price.incl_tax)
示例#6
0
 def test_price_equals_currency_matters(self):
     price1 = Price(currency='EUR', excl_tax=D('10.00'), tax=D('2.00'))
     price2 = Price(currency='USD', excl_tax=D('10.00'), tax=D('2.00'))
     self.assertNotEqual(price1, price2)
示例#7
0
 def test_price_equals_formats(self):
     price1 = Price(currency='USD', excl_tax=D('10.00'), tax=D('2.00'))
     price2 = Price(currency='USD',
                    excl_tax=D('10.00'),
                    incl_tax=D('12.00'))
     self.assertEqual(price1, price2)
示例#8
0
 def test_can_have_tax_set_later(self):
     price = Price('USD', D('10.00'))
     price.tax = D('2.00')
     self.assertEqual(D('12.00'), price.incl_tax)