Exemple #1
0
    def setUp(self):
        super().setUp()
        self.pclass = ProductClassFactory(name='T-Shirts', slug='tshirts')

        for attribute_type, __ in ProductAttribute.TYPE_CHOICES:
            values = {
                'type': attribute_type,
                'code': attribute_type,
                'product_class': self.pclass,
                'name': attribute_type,
            }
            if attribute_type == ProductAttribute.OPTION:
                option_group = factories.AttributeOptionGroupFactory()
                self.option = factories.AttributeOptionFactory(
                    group=option_group)
                values['option_group'] = option_group
            elif attribute_type == ProductAttribute.MULTI_OPTION:
                option_group = factories.AttributeOptionGroupFactory()
                self.multi_option = factories.AttributeOptionFactory(
                    group=option_group)
                values['option_group'] = option_group
            ProductAttributeFactory(**values)
        self.product = factories.ProductFactory(product_class=self.pclass)
        self.url = reverse('dashboard:catalogue-product',
                           kwargs={'pk': self.product.id})
 def setUp(self):
     super(JournalProductSerializerTest, self).setUp()
     product_class = ProductClassFactory(name="Journal")
     self.product = ProductFactory(product_class=product_class,
                                   stockrecords=[],
                                   categories="")
     StockRecordFactory(partner_sku="unit02",
                        product=self.product,
                        partner=PartnerFactory(short_code="dummy-partner"))
     ProductAttributeValueFactory(
         value=0.2,
         product=self.product,
         attribute=ProductAttributeFactory(product_class=product_class))
    def test_can_create_product_with_required_attributes(self):
        category = CategoryFactory()
        attribute = ProductAttributeFactory(required=True)
        product_class = attribute.product_class
        page = self.get(reverse('dashboard:catalogue-product-create',
                                args=(product_class.slug,)))
        form = page.form
        form['upc'] = '123456'
        form['title'] = 'new product'
        form['attr_weight'] = '5'
        form['productcategory_set-0-category'] = category.id
        form.submit()

        self.assertEqual(Product.objects.count(), 1)
Exemple #4
0
    def test_display_disallowed_delete_via_regular_window(self):
        self._set_up_display_delete_form_vars()
        self._set_up_display_delete_form_disallowed_vars()

        ProductAttributeFactory(type='multi_option',
                                name='Sizes',
                                code='sizes',
                                option_group=self.attribute_option_group)

        self.response = self.get(self.url)

        # Test the response
        self._test_display_delete_form_response()
        self._test_display_delete_disallowed_response()
        self._test_display_regular_window_response()
Exemple #5
0
    def test_display_delete_disallowed_via_popup_window(self):
        self._set_up_display_delete_form_vars()
        self._set_up_display_delete_form_disallowed_vars()
        self._set_up_pop_up_window_vars()

        ProductAttributeFactory(type='multi_option',
                                name='Sizes',
                                code='sizes',
                                option_group=self.attribute_option_group)

        params = {
            self.is_popup_var: self.is_popup,
        }
        querystring = urlencode(params)
        url = '%s?%s' % (self.url, querystring)
        self.response = self.get(url)

        # Test the response
        self._test_display_delete_form_response()
        self._test_display_delete_disallowed_response()
        self._test_display_delete_pop_up_window_response()
 def _create_dissalowed_object_factory(self):
     ProductAttributeFactory(type='multi_option',
                             name='Sizes',
                             code='sizes',
                             option_group=self.obj)