def test_product_variant_form(product): variant = product.variants.first() variant.name = '' variant.save() example_size = 'Small Size' data = {'attribute-size': example_size, 'sku': '1111', 'quantity': 2} form = ProductVariantForm(data, instance=variant) assert form.is_valid() form.save() variant.refresh_from_db() assert variant.name == example_size
def test_product_variant_form(product): variant = product.variants.first() variant.name = '' variant.save() example_size = 'Small Size' data = {'attribute-size': example_size, 'sku': '1111', 'quantity': 2} form = ProductVariantForm(data, instance=variant) assert form.is_valid() form.save() variant.refresh_from_db() assert variant.name == example_size
def test_product_variant_form(product, size_attribute): variant = product.variants.first() variant.name = "" variant.save() example_size = "Small Size" data = { "attribute-{}-{}".format(size_attribute.slug, size_attribute.pk): example_size, "sku": "1111", "quantity": 2, } form = ProductVariantForm(data, instance=variant) assert form.is_valid() form.save() variant.refresh_from_db() assert variant.name == example_size
def test_product_variant_form(product): variant = product.variants.first() variant.name = '' variant.save() example_size = 'Small Size' data = {'attribute-size': example_size, 'sku': '1111', 'quantity': 2} form = ProductVariantForm(data, instance=variant) assert form.is_valid() form.save() variant.refresh_from_db() assert variant.name == example_size assert response.status_code == 302 assert get_redirect_location(response) == reverse('dashboard:product-list') for p in product_list: p.refresh_from_db() assert not p.is_published
def test_product_variant_form(product, size_attribute): variant = product.variants.first() variant.name = "" variant.save() example_size = "Small Size" data = { "attribute-{}-{}".format(size_attribute.slug, size_attribute.pk): example_size, "sku": "1111", "quantity": 2, } form = ProductVariantForm(data, instance=variant) assert form.is_valid() form.save() variant.refresh_from_db() assert variant.name == example_size