Пример #1
0
def test_collection_form_name():
    data = {"name": "Test Collection", "products": []}
    form = CollectionForm(data)
    assert form.is_valid()

    collection = form.save()
    assert collection.slug == "test-collection"

    invalid_form = CollectionForm()
    assert not invalid_form.is_valid()
Пример #2
0
def test_collection_form_name():
    data = {'name': 'Test Collection', 'products': []}
    form = CollectionForm(data)
    assert form.is_valid()

    collection = form.save()
    assert collection.slug == 'test-collection'

    invalid_form = CollectionForm()
    assert not invalid_form.is_valid()
Пример #3
0
def test_collection_form_with_products(product):
    data = {"name": "Test collection", "products": [product.id]}
    form = CollectionForm(data)
    assert form.is_valid()

    collection = form.save()
    assert collection.products.count() == 1
Пример #4
0
def test_collection_form_with_products(product):
    data = {'name': 'Test collection', 'products': [product.id]}
    form = CollectionForm(data)
    assert form.is_valid()

    collection = form.save()
    assert collection.products.count() == 1