...My Relation Choice...'
>>> type_url + '/my_relation_choice' in browser.contents
True
Make sure it's editable via the 'settings' link::
>>> browser.getLink('Settings…').click()
>>> browser.url
'http://nohost/plone/dexterity-types/test_type/my_relation_choice'
Specify a couple of portal types to target::
>>> browser.getControl(name='form.widgets.portal_type:list').value = ['Event', 'Folder']
>>> browser.getControl(name='form.buttons.save').click()
>>> browser.getLink('Settings…').click()
>>> browser.getControl(name='form.widgets.portal_type:list').value
['Event', 'Folder']
Check to make sure test type is addable::
>>> browser.open(portal_url + '/++add++test_type')
>>> browser.contents
'...My Relation Choice...'
Now, let's demonstrate that the new type has a relation choice field::
>>> from zope.component import queryUtility
>>> from plone.dexterity.interfaces import IDexterityFTI
>>> fti = queryUtility(IDexterityFTI, name='test_type')
>>> fti
>>> schema = fti.lookupSchema()
>>> schema
>>> my_field = schema['my_relation_choice']
>>> my_field
And that that field has the expected source::
>>> my_field.source
And portal types::
>>> sorted(my_field.source.selectable_filter.criteria.get('portal_type'))
['Event', 'Folder']
-------------
Relation List
-------------
Add a test type::
Add a test type::
>>> browser.open(dexterity_types + '/@@add-type')
>>> browser.getControl(name='form.widgets.title').value = 'test type1'
>>> browser.getControl(name='form.widgets.id').value = 'test_type1'
>>> browser.getControl(name='form.buttons.add').click()
Add a relation list::
>>> type_url = 'http://nohost/plone/dexterity-types/test_type1'
>>> browser.open(type_url + '/@@add-field')
>>> browser.getControl(name='form.widgets.title').value = 'My Relation List'
>>> browser.getControl(name='form.widgets.__name__').value = 'my_relation_list'
>>> browser.getControl(name='form.widgets.factory:list').value = ['Relation List']
>>> browser.getControl(name='form.buttons.add').click()
>>> browser.url
'http://nohost/plone/dexterity-types/test_type1...'
>>> browser.contents
'...
...My Relation List...'
>>> type_url + '/my_relation_list' in browser.contents
True
Make sure it's editable via the 'settings' link::
>>> browser.getLink('Settings…').click()
>>> browser.url
'http://nohost/plone/dexterity-types/test_type1/my_relation_list'
Specify a couple of portal types to target::
>>> browser.getControl(name='form.widgets.portal_type:list').value = ['Event', 'Folder']
>>> browser.getControl(name='form.buttons.save').click()
>>> browser.getLink('Settings…').click()
>>> browser.getControl(name='form.widgets.portal_type:list').value
['Event', 'Folder']
Check to make sure test type is addable::
>>> browser.open(portal_url + '/++add++test_type1')
>>> browser.contents
'...My Relation List...'
Now, let's demonstrate that the new type has a relation list field::
>>> from zope.component import queryUtility
>>> from plone.dexterity.interfaces import IDexterityFTI
>>> fti = queryUtility(IDexterityFTI, name='test_type1')
>>> fti
>>> schema = fti.lookupSchema()
>>> schema
>>> my_field = schema['my_relation_list']
>>> my_field
And that that field has the expected value_type source::
>>> my_field.value_type.source
And portal types::
>>> sorted(my_field.value_type.source.selectable_filter.criteria.get('portal_type'))
['Event', 'Folder']