<s> from django . test import TestCase <EOL> from oscar . apps . dashboard . catalogue import forms <EOL> from oscar . test import factories <EOL> class TestCreateProductForm ( TestCase ) : <EOL> def setUp ( self ) : <EOL> self . product_class = factories . ProductClassFactory ( ) <EOL> def submit ( self , data , parent = None ) : <EOL> return forms . ProductForm ( self . product_class , parent = parent , data = data ) <EOL> def test_validates_that_parent_products_must_have_title ( self ) : <EOL> form = self . submit ( { '<STR_LIT>' : '<STR_LIT>' } ) <EOL> self . assertFalse ( form . is_valid ( ) ) <EOL> form = self . submit ( { '<STR_LIT>' : '<STR_LIT>' , '<STR_LIT:title>' : '<STR_LIT:foo>' } ) <EOL> self . assertTrue ( form . is_valid ( ) ) <EOL> def test_validates_that_child_products_dont_need_a_title ( self ) : <EOL> parent = factories . ProductFactory ( <EOL> product_class = self . product_class , structure = '<STR_LIT>' ) <EOL> form = self . submit ( { '<STR_LIT>' : '<STR_LIT>' } , parent = parent ) <EOL> self . assertTrue ( form . is_valid ( ) ) <EOL> class TestCreateProductAttributeForm ( TestCase ) : <EOL> def test_can_create_without_code ( self ) : <EOL> form = forms . ProductAttributesForm ( data = { <EOL> "<STR_LIT:name>" : "<STR_LIT>" , <EOL> "<STR_LIT:type>" : "<STR_LIT:text>" <EOL> } ) <EOL> self . assertTrue ( form . is_valid ( ) ) <EOL> product_attribute = form . save ( ) <EOL> self . assertTrue ( product_attribute . code ) </s>
