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
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
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()
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()