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)
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)
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)
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())
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))
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))
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)
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')
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')
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)
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'))
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)
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)
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)
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')
def setUp(self): self.repo = repository.Repository() self.basket = Basket()
def setUp(self): self.method = methods.Free() self.basket = Basket() self.charge = self.method.calculate(self.basket)
def setUp(self): self.product = create_product(price=D('12.00'), num_in_stock=5) self.basket = Basket() self.basket.add_product(self.product)
def setUp(self): self.condition = custom.create_condition(BasketOwnerCalledBarry) self.offer = models.ConditionalOffer(condition=self.condition) self.basket = Basket()
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)
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)
def setUp(self): self.creator = OrderCreator() self.basket = Basket()
def setUp(self): self.method = methods.FixedPrice(D('10.00')) basket = Basket() self.charge = self.method.calculate(basket)
def setUp(self): self.basket = Basket() self.basket.strategy = strategy.Default()
def test_new_baskets_are_empty(self): self.assertTrue(Basket().is_empty)
def test_empty_baskets_have_zero_lines(self): self.assertTrue(Basket().num_lines == 0)
def test_returns_zero_for_empty_basket(self): basket = Basket() scales = Scales(attribute_code='weight') self.assertEqual(0, scales.weigh_basket(basket))
def test_delegates_is_tax_known(self): basket = Basket() charge = self.method.calculate(basket) self.assertTrue(charge.is_tax_known)
def setUp(self): self.method = methods.NoShippingRequired() basket = Basket() self.charge = self.method.calculate(basket)
def test_discounts_charge(self): basket = Basket() charge = self.method.calculate(basket) self.assertEqual(D('7.00'), charge.incl_tax)