Doctest for Products.DataGridField

Hi, has anyone written a doctest for a Products.DataGridField?
In my example I have 4 columns, the first one is a SelectColumn.

On the doctest I am able to select the value on the dropdown and save it like this:

>>> client
<Client at /plone/clients/client-1>
>>> client_url = client.absolute_url() + '/base_edit'
>>> browser.open(client_url)
>>> browser.getControl('My Client Type').selected = True
>>> browser.getControl(name='form.button.save').click()
>>> 'Changes saved' in browser.contents
True 
>>> browser.open(client_url)
>>> browser.getControl('My Client Type')
<ItemControl name='Licenses.LicenseType:records' type='select' 
optionValue='257e2ce2c40b47e08c2097e8a4cd485e' selected=False>

As you can see the value is not selected.

Off-topic: writing doctests is out.

-aj

1 Like

As Andreas already mentioned I would also not recommend to use doctests, but robot tests instead.

If you need to use them anyway, you could take a look at the doctests for collective.z3cform.datagridfield, which is the z3c.form version of Products.DataGridField.

3 Likes