I'm writing a functional test for a content type that has, among other, the following fields:

    StringField('role',
        widget=MasterSelectWidget(
            label=_(u'Role'),
            slave_fields=(
                {'name': 'record_number',
                 'action': 'hide',
                 'hide_values': (READER, )},
                ),
            ),
        vocabulary=DisplayList((
            (READER, 'Reader'),
            (JUDGE, 'Judge'),
            )),
        ),

    StringField('record',
        widget=StringWidget(
            label=_(u'Record'),
            ),
        ),

    DataGridField('students',
        required=True,
        columns=('register', 'name'),
        widget=DataGridWidget(
            auto_insert=False,
            label=_(u'Students'),
            columns={
                  'register': Column(u'Register'),
                  'name': Column(u'Name'),
                  },
            ),
        allow_empty_rows=False,
        allow_oddeven=True,
        ),

in the first part of my test I create the content type, and give a value to "role" and "students":

    >>> add_link = browser.getLink(id='examiner')
    >>> add_link.click()
    >>> browser.getControl(name='title').value = 'Test'
>>> browser.getControl(name='role').getControl('Reader').selected = True >>> browser.getControl(name='students.register:records').value = '12345'
    >>> browser.getControl(name='students.name:records').value = 'John Doe'
    >>>     >>> browser.getControl(name='form.button.save').click()
    >>> 'test' in folder.objectIds()
    True

in the second part I want to edit the of "role" to test a validator that enforces "record" is not empty:

    >>> url = '%s/test/edit' % folder.absolute_url()
    >>> browser.open(url)
    >>> browser.getControl(name='role').getControl('Judge').selected = True
    >>> browser.getControl(name='form.button.save').click()
    >>> 'You need to specify a record number' in browser.contents
    True
    >>> browser.getControl(name='record').value = '12345'
    >>> browser.getControl(name='form.button.save').click()
    >>> browser.contents
    >>> 'Changes saved.' in browser.contents
    True

the last test fails because, at this point, the DataGridField records, "register" and "name", are empty and I don't know why.

do DataGridFields are populated using JavaScript? do I need to populate again the records on the field? how can I test something like this?

best regards
--
Héctor Velarde

Attachment: smime.p7s
Description: S/MIME Cryptographic Signature

_______________________________________________
Product-Developers mailing list
[email protected]
https://lists.plone.org/mailman/listinfo/plone-product-developers

Reply via email to