Ejemplo n.º 1
0
 def test_create_line_reference(self):
     basket = BasketFactory()
     product = ProductFactory(title="A product")
     option = OptionFactory(name="product_option", code="product_option")
     option_product = ProductFactory(title=u'Asunción')
     options = [{'option': option, 'value': option_product}]
     basket.add_product(product, options=options)
Ejemplo n.º 2
0
 def test_add_to_basket_with_not_required_option(self):
     option = OptionFactory(required=False)
     self.product.product_class.options.add(option)
     data = {'quantity': 1}
     form = self._get_basket_form(
         basket=self.basket,
         product=self.product,
         data=data,
     )
     self.assertTrue(form.is_valid())
     self.assertFalse(form.fields[option.code].required)
    def test_display_pagination_navigation(self):
        url_name = 'dashboard:catalogue-option-list'
        per_page = settings.OSCAR_DASHBOARD_ITEMS_PER_PAGE
        option_name = 'Test Option #%d'

        for i in range(0, int(1.5 * per_page)):
            name = option_name % i
            OptionFactory(name=name, code=slugify(name))

        page = self.get(reverse(url_name))

        # Test the pagination
        self.assertContains(page, 'Page 1 of 2')
Ejemplo n.º 4
0
 def _test_add_to_basket_with_specific_option_type(self, option_type,
                                                   invalid_value,
                                                   valid_value):
     option = OptionFactory(required=True, type=option_type)
     self.product.product_class.options.add(option)
     data = {'quantity': 1, option.code: invalid_value}
     invalid_form = self._get_basket_form(
         basket=self.basket,
         product=self.product,
         data=data,
     )
     self.assertFalse(invalid_form.is_valid())
     data[option.code] = valid_value
     valid_form = self._get_basket_form(
         basket=self.basket,
         product=self.product,
         data=data,
     )
     self.assertTrue(valid_form.is_valid())
Ejemplo n.º 5
0
 def test_basket_option_field_exists(self):
     option = OptionFactory()
     self.product.product_class.options.add(option)
     form = self._get_basket_form(basket=self.basket, product=self.product)
     self.assertIn(option.code, form.fields)
Ejemplo n.º 6
0
 def _create_object_factory(self):
     return OptionFactory()
Ejemplo n.º 7
0
 def _create_object(self, idx):
     option_name = 'Test Option #%d'
     name = option_name % idx
     OptionFactory(name=name, code=slugify(name))
    def setUp(self):
        super().setUp()

        self.option = OptionFactory()