[Grok-dev] Help on functional doctest for List component

Christian Klinger cklinger at novareto.de
Tue Oct 13 05:04:04 EDT 2009


Hi Kris,

so i tried your form. I run into the same trouble.
The problem is that the widget with the two boxes
are difficult, at least for me, to test in the testbrowser.

So the name for the second box is:

   form.getControl(name='form.data_types.to')

but i can not assign values to it. Because this box has
no options in it.
This is what the javascript does, it moves the options
from the first box to the second. :(


If you don't need this special widget you can use a
normal multiselction widget. Then the test will work.

Sorry for not finding a better solution...
Christian


> Hi Christian,
>
> As you asked, I send you the Form and interface code:
>
> class *AddCandidateForm*(grok.AddForm):
>
> grok.context(IResultGroup)
>
> form_fields = grok.AutoFields(ICandidate)
>
> grok.name(/'add_candidate'/)
>
> /@grok.action/(/'Add Candidate'/)
>
> def *Add*(/self/, **data):
>
> cnd = component.createObject(u/'arts.models.Candidate'/)
>
> /self/.applyData(cnd, **data)
>
> /self/.context.addCandidate(cnd)
>
> /self/.redirect(/self/.url(cnd) )
>
> class *ICandidate*(Interface):
>
> video = schema.Choice(title=u/'Video'/
>
> , description=u/'What video sequence is this candidate for?'/
>
> , required = True
>
> , source=sources.VideoSource())
>
> data_types = schema.List(title=u/'Data Type(s)'/
>
> , description=u/'What type(s) of data does this candidate contain?'/
>
> , required = True
>
> ,value_type=schema.Choice(source=sources.CandidateDataTypeSource()))
>
> data_format = schema.Choice(title=u/'Data Format'/
>
> , description=u/'What is the format of the data?'/
>
> , required = True
>
> , source=sources.DataFormatSource())
>
> file = schema.Bytes(title=u/'Candidate File'/
>
> , description=u/'The File containing the data'/
>
> , required = True)
>
> platform = schema.Choice(title=u/'Hardware Platform'/
>
> , description=u/'What Hardware Platform was this test run on?'/
>
> , required = True
>
> , source=sources.PlatformSource())
>
> board = schema.TextLine(title=u/'hardware ID'/)
>
> The “*Data Type(s)” label could not be looked up as you can see in the
> error message:
>
> File
> "c:\clearcase\kdg_view_art\qualitycontrol\art_server\src\arts\all_tests\products_doctest.txt",
>
> line 278, in products_doctest.txt
>
> Failed example:
>
> browser.getControl('*Data Type(s)').value = ['Inverse Directions',]
>
> Exception raised:
>
> Traceback (most recent call last):
>
> File "c:\documents and
> settings\kdg\.buildout\eggs\zope.testing-3.6.0-py2.5.egg\zope\testing\d
>
> octest.py", line 1356, in __run
>
> compileflags, 1) in test.globs
>
> File "<doctest products_doctest.txt[74]>", line 1, in <module>
>
> browser.getControl('*Data Type(s)').value = ['Inverse Directions',]
>
> File "c:\documents and
> settings\kdg\.buildout\eggs\zope.testbrowser-3.4.2-py2.5.egg\zope\testb
>
> rowser\browser.py", line 337, in getControl
>
> control, form = disambiguate(intermediate, msg, index)
>
> File "c:\documents and
> settings\kdg\.buildout\eggs\zope.testbrowser-3.4.2-py2.5.egg\zope\testb
>
> rowser\browser.py", line 50, in disambiguate
>
> raise LookupError(msg)
>
> LookupError: label '*Data Type(s)'
>
> Any idea to make a selection for the ‘*Data Type(s)’ control?
>
> Best regards,
>
> *Kris Degryse*
> *R&D Test Engineer*
>
>
>
>
> _______________________________________________
> Grok-dev mailing list
> Grok-dev at zope.org
> https://mail.zope.org/mailman/listinfo/grok-dev




More information about the Grok-dev mailing list