Exemplo n.º 1
0
 def prepare_basket(self, price):
     """ Helper function that creates a basket and adds a product with set price to it. """
     basket = factories.BasketFactory(owner=self.user, site=self.site)
     basket.add_product(
         factories.ProductFactory(stockrecords__price_excl_tax=price), 1)
     self.assertEqual(basket.lines.count(), 1)
     self.assertEqual(basket.total_incl_tax, Decimal(price))
Exemplo n.º 2
0
    def test_non_seat_product(self):
        """Verify the basket accepts non-seat product types."""
        title = 'Test Product 123'
        description = 'All hail the test product.'
        product = factories.ProductFactory(title=title, description=description)
        self.create_basket_and_add_product(product)

        response = self.client.get(self.path)
        self.assertEqual(response.status_code, 200)
        line_data = response.context['formset_lines_data'][0][1]
        self.assertEqual(line_data['product_title'], title)
        self.assertEqual(line_data['product_description'], description)
Exemplo n.º 3
0
 def test_voucher_not_valid_for_bundle(self):
     """ Verify correct error message is returned when voucher is used against a bundle. """
     self.mock_access_token_response()
     self.mock_account_api(self.request, self.user.username, data={'is_active': True})
     voucher, product = prepare_voucher(code=COUPON_CODE, benefit_value=0)
     new_product = factories.ProductFactory(categories=[], stockrecords__partner__short_code='second')
     self.basket.add_product(product)
     self.basket.add_product(new_product)
     BasketAttributeType.objects.get_or_create(name=BUNDLE)
     BasketAttribute.objects.update_or_create(
         basket=self.basket,
         attribute_type=BasketAttributeType.objects.get(name=BUNDLE),
         value_text='test_bundle'
     )
     self.assert_form_valid_message("Coupon code '{code}' is not valid for this basket.".format(code=voucher.code))