def test_create_form(self): """Create form should create fields from the JSON""" crowdsource = CrowdsourceFactory() CrowdsourceTextFieldFactory( crowdsource=crowdsource, label='Delete Me', order=0, ) crowdsource.create_form( json.dumps([ { 'label': 'Text Field', 'type': 'text', 'description': 'Here is some help', }, { 'label': 'Select Field', 'type': 'select', 'values': [ { 'label': 'Choice 1', 'value': 'choice-1', }, { 'label': 'Choice 2', 'value': 'choice-2', }, ], }, ]) ) assert_false(crowdsource.fields.filter(label='Delete Me').exists()) ok_( crowdsource.fields.filter( label='Text Field', type='text', help_text='Here is some help', order=0, ).exists() ) ok_( crowdsource.fields.filter( label='Select Field', type='select', order=1, ).exists() ) eq_(crowdsource.fields.get(label='Select Field').choices.count(), 2)
def test_create_form(self): """Create form should create fields from the JSON""" crowdsource = CrowdsourceFactory() CrowdsourceTextFieldFactory(crowdsource=crowdsource, label="Delete Me", order=0) crowdsource.create_form( json.dumps([ { "label": "Text Field", "type": "text", "description": "Here is some help", }, { "label": "Select Field", "type": "select", "values": [ { "label": "Choice 1", "value": "choice-1" }, { "label": "Choice 2", "value": "choice-2" }, ], }, ])) ok_(crowdsource.fields.get(label="Delete Me").deleted) ok_( crowdsource.fields.filter(label="Text Field", type="text", help_text="Here is some help", order=0).exists()) ok_( crowdsource.fields.filter(label="Select Field", type="select", order=1).exists()) eq_(crowdsource.fields.get(label="Select Field").choices.count(), 2)