Beispiel #1
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)
Beispiel #2
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)
Beispiel #3
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)
Beispiel #4
0
 def setUp(self):
     self.strategy = strategy.Default()
     parent = factories.create_product(structure='parent')
     factories.create_product(parent=parent,
                              price=D('10.00'),
                              num_in_stock=3)
     for x in range(2):
         factories.create_product(parent=parent)
     self.info = self.strategy.fetch_for_parent(parent)
Beispiel #5
0
    def test_can_reorder_a_previous_order(self):
        order_history_page = self.app.get(
            reverse('customer:order', args=[self.order.number]), user=self.user)
        form = order_history_page.forms['order_form_%d' % self.order.id]
        form.submit()

        basket = Basket.open.get(owner=self.user)
        basket.strategy = strategy.Default()
        self.assertEqual(1, basket.all_lines().count())
Beispiel #6
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'))
Beispiel #7
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_excl_tax=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)
Beispiel #8
0
    def test_can_reorder_a_previous_order_line(self):
        order_history_page = self.app.get(
            reverse('customer:order',
                    kwargs={'order_number': self.order.number}),
            user=self.user)
        line = self.order.lines.all()[0]
        form = order_history_page.forms['line_form_%d' % line.id]
        form.submit()

        basket = Basket.open.get(owner=self.user)
        basket.strategy = strategy.Default()
        self.assertEqual(1, basket.all_lines().count())
Beispiel #9
0
    def test_cannot_reorder_line_when_basket_maximum_exceeded(self):
        order = create_order(user=self.user)
        line = order.lines.all()[0]

        product = create_product(price=D('12.00'))
        product_page = self.get(line.product.get_absolute_url())
        product_page.forms['add_to_basket_form'].submit()

        basket = Basket.objects.all()[0]
        basket.strategy = strategy.Default()
        self.assertEqual(len(basket.all_lines()), 1)

        # Try to reorder a line
        order_page = self.get(reverse('customer:order', args=(order.number,)))
        order_page.forms['line_form_%s' % line.id].submit()

        self.assertEqual(len(basket.all_lines()), 1)
        self.assertNotEqual(line.product.pk, product.pk)
Beispiel #10
0
 def setUp(self):
     self.basket = Basket()
     self.basket.strategy = strategy.Default()
     self.basket.submit()
Beispiel #11
0
 def setUp(self):
     self.strategy = strategy.Default()
     parent = factories.create_product(structure='parent')
     for x in range(3):
         factories.create_product(parent=parent)
     self.info = self.strategy.fetch_for_parent(parent)
Beispiel #12
0
 def setUp(self):
     self.strategy = strategy.Default()