Ejemplo n.º 1
0
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
Ejemplo n.º 2
0
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
Ejemplo n.º 3
0
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
Ejemplo n.º 4
0
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
Ejemplo n.º 5
0
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