コード例 #1
0
ファイル: basket_tests.py プロジェクト: jeddison/django-oscar
 def setUp(self):
     self.product = create_product()
     self.user_basket = Basket()
     self.user_basket.add_product(self.product)
     self.cookie_basket = Basket()
     self.cookie_basket.add_product(self.product, 2)
     self.user_basket.merge(self.cookie_basket, add_quantities=False)
コード例 #2
0
 def setUp(self):
     self.product = create_product(num_in_stock=10)
     self.user_basket = Basket()
     self.user_basket.strategy = strategy.Default()
     add_product(self.user_basket, product=self.product)
     self.cookie_basket = Basket()
     self.cookie_basket.strategy = strategy.Default()
     add_product(self.cookie_basket, quantity=2, product=self.product)
     self.user_basket.merge(self.cookie_basket, add_quantities=False)
コード例 #3
0
    def setUp(self):
        self.product = factories.create_product()
        self.record = factories.create_stockrecord(self.product,
                                                   price_excl_tax=D('10.00'))
        self.purchase_info = factories.create_purchase_info(self.record)

        self.main_basket = Basket()
        self.main_basket.strategy = strategy.Default()
        self.main_basket.add(self.product, quantity=2)

        self.merge_basket = Basket()
        self.merge_basket.strategy = strategy.Default()
        self.merge_basket.add(self.product, quantity=1)

        self.main_basket.merge(self.merge_basket)
コード例 #4
0
ファイル: shipping_tests.py プロジェクト: waytai/django-oscar
 def test_different_values(self):
     shipping_values = ['1.00', '5.00', '10.00', '12.00']
     for value in shipping_values:
         basket = Basket()
         method = FixedPrice(D(value))
         method.set_basket(basket)
         self.assertEquals(D(value), method.basket_charge_excl_tax())
コード例 #5
0
ファイル: shipping_tests.py プロジェクト: waytai/django-oscar
    def test_weight_calculation_of_basket(self):
        basket = Basket()
        basket.add_product(create_product(attributes={'weight': 1}))
        basket.add_product(create_product(attributes={'weight': 2}))

        scales = Scales(attribute_code='weight')
        self.assertEquals(1 + 2, scales.weigh_basket(basket))
コード例 #6
0
    def test_weight_calculation_of_basket_with_line_quantity(self):
        basket = Basket()
        basket.add_product(create_product(attributes={'weight': 1}), quantity=3)
        basket.add_product(create_product(attributes={'weight': 2}), quantity=4)

        scales = Scales(attribute_code='weight')
        self.assertEquals(1*3+2*4, scales.weigh_basket(basket))
コード例 #7
0
 def setUp(self):
     self.basket = Basket()
     self.basket.strategy = strategy.Default()
     self.product = factories.create_product()
     self.record = factories.create_stockrecord(self.product,
                                                price_excl_tax=D('10.00'))
     self.purchase_info = factories.create_purchase_info(self.record)
     self.basket.add(self.product, 10)
コード例 #8
0
 def setUp(self):
     basket = Basket()
     basket.add_product(create_product(price=D('10.00')), 4)
     self.order = create_order(number='100002', basket=basket)
     self.line = self.order.lines.all()[0]
     self.order_placed, _ = ShippingEventType.objects.get_or_create(
         code='order_placed', name='Order placed')
     self.dispatched, _ = ShippingEventType.objects.get_or_create(
         code='dispatched', name='Dispatched')
コード例 #9
0
 def test_basket_lines_are_converted_to_xml(self):
     product = factories.create_product(price=D('12.99'))
     basket = Basket()
     basket.add_product(product)
     data = the3rdman.build_data_dict(basket=basket)
     doc = the3rdman.add_fraud_fields(**data)
     xml = doc.toxml()
     self.assertXmlElementEquals(
         xml, '3', 'The3rdMan.CustomerInformation.sales_channel')
コード例 #10
0
 def setUp(self):
     self.basket = Basket()
     self.basket.strategy = strategy.Default()
     self.product = factories.create_product()
     self.record = factories.create_stockrecord(currency='GBP',
                                                product=self.product,
                                                price=D('10.00'))
     self.purchase_info = factories.create_purchase_info(self.record)
     self.basket.add(self.product)
コード例 #11
0
    def test_line_tax_for_zero_tax_strategies(self):
        basket = Basket()
        basket.strategy = strategy.Default()
        product = factories.create_product()
        # Tax for the default strategy will be 0
        factories.create_stockrecord(
            product, price_excl_tax=D('75.00'), num_in_stock=10)
        basket.add(product, 1)

        self.assertEqual(basket.lines.first().line_tax, D('0'))
コード例 #12
0
    def setUp(self):
        basket = Basket()
        basket.add_product(create_product(price=D('10.00')), 4)
        self.order = create_order(number='100002', basket=basket)
        self.line = self.order.lines.all()[0]

        self.shipped, _ = ShippingEventType.objects.get_or_create(
            name='Shipped', is_required=True, sequence_number=0)
        self.returned, _ = ShippingEventType.objects.get_or_create(
            name='Returned', is_required=False, sequence_number=1)
コード例 #13
0
    def test_totals_for_free_products(self):
        basket = Basket()
        basket.strategy = strategy.Default()
        # Add a zero-priced product to the basket
        product = factories.create_product()
        factories.create_stockrecord(product, price=D('0.00'), num_in_stock=10)
        basket.add(product, 1)

        self.assertEqual(basket.lines.count(), 1)
        self.assertEqual(basket.total_excl_tax, 0)
        self.assertEqual(basket.total_incl_tax, 0)
コード例 #14
0
    def test_line_tax_for_unknown_tax_strategies(self):
        class UnknownTaxStrategy(strategy.Default):
            """ A test strategy where the tax is not known """
            def pricing_policy(self, product, stockrecord):
                return prices.FixedPrice('GBP', stockrecord.price, tax=None)

        basket = Basket()
        basket.strategy = UnknownTaxStrategy()
        product = factories.create_product()
        factories.create_stockrecord(product, num_in_stock=10)
        basket.add(product, 1)

        self.assertEqual(basket.lines.first().line_tax, None)
コード例 #15
0
    def test_basket_lines_are_converted_to_xml(self):
        product = factories.create_product(price=D('12.99'))
        basket = Basket()

        # Nasty hack to make test suite work with both Oscar 0.5 and 0.6
        try:
            from oscar.apps.partner import strategy
        except ImportError:
            pass
        else:
            basket.strategy = strategy.Default()

        basket.add_product(product)
        data = the3rdman.build_data_dict(basket=basket)
        doc = the3rdman.add_fraud_fields(**data)
        xml = doc.toxml()
        self.assertXmlElementEquals(
            xml, '3', 'The3rdMan.CustomerInformation.sales_channel')
コード例 #16
0
 def setUp(self):
     self.repo = repository.Repository()
     self.basket = Basket()
コード例 #17
0
 def setUp(self):
     self.method = methods.Free()
     self.basket = Basket()
     self.charge = self.method.calculate(self.basket)
コード例 #18
0
 def setUp(self):
     self.product = create_product(price=D('12.00'), num_in_stock=5)
     self.basket = Basket()
     self.basket.add_product(self.product)
コード例 #19
0
 def setUp(self):
     self.condition = custom.create_condition(BasketOwnerCalledBarry)
     self.offer = models.ConditionalOffer(condition=self.condition)
     self.basket = Basket()
コード例 #20
0
 def setUp(self):
     self.method = methods.FixedPrice(
         charge_excl_tax=D('10.00'),
         charge_incl_tax=D('12.00'))
     basket = Basket()
     self.charge = self.method.calculate(basket)
コード例 #21
0
 def test_can_have_tax_set_later(self):
     basket = Basket()
     charge = self.method.calculate(basket)
     charge.tax = D('1.00')
     self.assertEqual(D('9.00'), charge.incl_tax)
コード例 #22
0
 def setUp(self):
     self.creator = OrderCreator()
     self.basket = Basket()
コード例 #23
0
 def setUp(self):
     self.method = methods.FixedPrice(D('10.00'))
     basket = Basket()
     self.charge = self.method.calculate(basket)
コード例 #24
0
 def setUp(self):
     self.basket = Basket()
     self.basket.strategy = strategy.Default()
コード例 #25
0
 def test_new_baskets_are_empty(self):
     self.assertTrue(Basket().is_empty)
コード例 #26
0
 def test_empty_baskets_have_zero_lines(self):
     self.assertTrue(Basket().num_lines == 0)
コード例 #27
0
    def test_returns_zero_for_empty_basket(self):
        basket = Basket()

        scales = Scales(attribute_code='weight')
        self.assertEqual(0, scales.weigh_basket(basket))
コード例 #28
0
 def test_delegates_is_tax_known(self):
     basket = Basket()
     charge = self.method.calculate(basket)
     self.assertTrue(charge.is_tax_known)
コード例 #29
0
 def setUp(self):
     self.method = methods.NoShippingRequired()
     basket = Basket()
     self.charge = self.method.calculate(basket)
コード例 #30
0
 def test_discounts_charge(self):
     basket = Basket()
     charge = self.method.calculate(basket)
     self.assertEqual(D('7.00'), charge.incl_tax)