You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1234567891011121314151617181920212223242526272829
  1. from decimal import Decimal as D
  2. from oscar.test import factories
  3. from oscar.apps.partner import strategy
  4. def add_product(basket, price=None, quantity=1, product=None):
  5. """
  6. Helper to add a product to the basket.
  7. """
  8. if not hasattr(basket, 'strategy'):
  9. basket.strategy = strategy.Default()
  10. if price is None:
  11. price = D('1')
  12. if product and product.has_stockrecords:
  13. record = product.stockrecords.all()[0]
  14. else:
  15. record = factories.create_stockrecord(
  16. product=product, price_excl_tax=price,
  17. num_in_stock=quantity + 1)
  18. basket.add_product(record.product, quantity)
  19. def add_products(basket, args):
  20. """
  21. Helper to add a series of products to the passed basket
  22. """
  23. for price, quantity in args:
  24. add_product(basket, price, quantity)