Help on functional doctest for List component

View: New views
6 Messages — Rating Filter:   Alert me  

Help on functional doctest for List component

by Kris Degryse-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Some parts of this message have been removed. Learn more about Nabble's security policy.

Dear,

 

I’m having a problem with writing a functional doctest for a List control item.

 

How can I make a selection for the “to” selection box? The List component is displayed in a browser as several widgets (two selection boxes and four buttons). Because javascript code is behind the buttons, it is impossible to simulate a click on one of those four buttons.

 

Functional doctest should look like this:

   >>> browser.getControl(name=’form.data_types.from’).getControl(‘Item’).selected = True

  >>> Here I want to simulate the onclick event of the “ ->” button next to the selection so it moves to the “from” box, but how?

 

Or is there another way to make the selection for the “from” box?

 

Best regards,

 

Kris Degryse
R&D Test Engineer

 

 


_______________________________________________
Grok-dev mailing list
Grok-dev@...
https://mail.zope.org/mailman/listinfo/grok-dev

Re: Help on functional doctest for List component

by Christian Klinger :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi Kris:

can you show me the html of your form before you
try to get the controls

 >>> print browser.contents

With the help of this contents i can show you the how
you can get your control. I think...

Christian

> Dear,
>
>  
>
> I’m having a problem with writing a functional doctest for a List
> control item.
>
>  
>
> How can I make a selection for the “to” selection box? The List
> component is displayed in a browser as several widgets (two selection
> boxes and four buttons). Because javascript code is behind the buttons,
> it is impossible to simulate a click on one of those four buttons.
>
>  
>
> Functional doctest should look like this:
>
>    >>>
> browser.getControl(name=’form.data_types.from’).getControl(‘Item’).selected
> = True
>
>   >>> Here I want to simulate the onclick event of the “ ->” button next
> to the selection so it moves to the “from” box, but how?
>
>  
>
> Or is there another way to make the selection for the “from” box?
>
>  
>
> Best regards,
>
>  
>
> *Kris Degryse*
> *R&D Test Engineer*
>
>  
>
>  
>
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> Grok-dev mailing list
> Grok-dev@...
> https://mail.zope.org/mailman/listinfo/grok-dev

_______________________________________________
Grok-dev mailing list
Grok-dev@...
https://mail.zope.org/mailman/listinfo/grok-dev

Parent Message unknown Re: Help on functional doctest for List component

by Kris Degryse-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Some parts of this message have been removed. Learn more about Nabble's security policy.

Dear Christian,

 

Underneath a screen shot of the “Add Candidate” form that I want to test in the zope testbrowser through a doctest file.

In this doctest file I would like to fill in or make a selection for each control and press the “Add Candidate” button.

>>> browser.getControl(‘Video’).selected = True

                Here I don’t know how to make a  selection for the “*Data Type(s)”???

>>> browser.getControl('Data Format').getControl('XML').selected = True

      >>> import cStringIO

      >>> browser.getControl('Candidate File').add_file(cStringIO.StringIO('Candidate file contents'),'application/octet-stream','C:\\Temp\Candidate.log')

      >>> browser.getControl('Hardware Platform').getControl('win32').selected = True

      >>> browser.getControl('*hardware ID').value = 'Offline'

 

After the screen shot is my HTML

 

Thanks anyway,

Kris Degryse

 

<body>

<form action="http://localhost:8080/arts/Products/VIP-T/V2.09/ResultGroup1/addcandidate"

      method="post" class="edit-form"

      enctype="multipart/form-data">

  <table class="form-fields">

    <tbody>

        <tr>

          <td class="label">

            <label for="form.video">

              <span>Video</span>

            </label>

          </td>

          <td class="field">

            <div class="widget"><div>

<div class="value">

<select id="form.video" name="form.video" size="1" >

<option value="0x086c">Video</option>

</select>

</div>

<input name="form.video-empty-marker" type="hidden" value="1" />

</div></div>

          </td>

        </tr>

        <tr>

          <td class="label">

            <label for="form.data_types">

              <span class="required">*</span><span>Data Type(s)</span>

            </label>

          </td>

          <td class="field">

            <div class="widget"><script type="text/javascript">

 

function moveItems(from, to)

  {

  // shortcuts for selection fields

  var src = document.getElementById(from);

  var tgt = document.getElementById(to);

 

  if (src.selectedIndex == -1) selectionError();

  else

    {

    // iterate over all selected items

    // --> attribute "selectedIndex" doesn't support multiple selection.

    // Anyway, it works here, as a moved item isn't selected anymore,

    // thus "selectedIndex" indicating the "next" selected item :)

    while (src.selectedIndex > -1)

      if (src.options[src.selectedIndex].selected)

        {

        // create a new virtal object with values of item to copy

        temp = new Option(src.options[src.selectedIndex].text,

                      src.options[src.selectedIndex].value);

        // append virtual object to targe

        tgt.options[tgt.length] = temp;

        // want to select newly created item

        temp.selected = true;

        // delete moved item in source

        src.options[src.selectedIndex] = null;

      }

    }

  }

 

// move item from "from" selection to "to" selection

function from2to(name)

  {

  moveItems(name+".from", name+".to");

  copyDataForSubmit(name);

  }

 

// move item from "to" selection back to "from" selection

function to2from(name)

  {

  moveItems(name+".to", name+".from");

  copyDataForSubmit(name);

  }

 

function swapFields(a, b)

  {

  // swap text

  var temp = a.text;

  a.text = b.text;

  b.text = temp;

  // swap value

  temp = a.value;

  a.value = b.value;

  b.value = temp;

  // swap selection

  temp = a.selected;

  a.selected = b.selected;

  b.selected = temp;

  }

 

// move selected item in "to" selection one up

function moveUp(name)

  {

  // shortcuts for selection field

  var toSel = document.getElementById(name+".to");

 

  if (toSel.selectedIndex == -1)

      selectionError();

  else if (toSel.options[0].selected)

      alert("Cannot move further up!");

  else for (var i = 0; i < toSel.length; i++)

    if (toSel.options[i].selected)

      {

      swapFields(toSel.options[i-1], toSel.options[i]);

      copyDataForSubmit(name);

      }

  }

 

// move selected item in "to" selection one down

function moveDown(name)

  {

    // shortcuts for selection field

    var toSel = document.getElementById(name+".to");

 

    if (toSel.selectedIndex == -1) {

        selectionError();

    } else if (toSel.options[toSel.length-1].selected) {

        alert("Cannot move further down!");

    } else {

      for (var i = toSel.length-1; i >= 0; i--) {

        if (toSel.options[i].selected) {

          swapFields(toSel.options[i+1], toSel.options[i]);

        }

      }

      copyDataForSubmit(name);

    }

  }

 

// copy each item of "toSel" into one hidden input field

function copyDataForSubmit(name)

  {

  // shortcuts for selection field and hidden data field

  var toSel = document.getElementById(name+".to");

  var toDataContainer = document.getElementById(name+".toDataContainer");

 

  // delete all child nodes (--> complete content) of "toDataContainer" span

  while (toDataContainer.hasChildNodes())

      toDataContainer.removeChild(toDataContainer.firstChild);

 

  // create new hidden input fields - one for each selection item of

  // "to" selection

  for (var i = 0; i < toSel.options.length; i++)

    {

    // create virtual node with suitable attributes

    var newNode = document.createElement("input");

    var newAttr = document.createAttribute("name");

    newAttr.nodeValue = name;

    newNode.setAttributeNode(newAttr);

 

    newAttr = document.createAttribute("type");

    newAttr.nodeValue = "hidden";

    newNode.setAttributeNode(newAttr);

 

    newAttr = document.createAttribute("value");

    newAttr.nodeValue = toSel.options[i].value;

    newNode.setAttributeNode(newAttr);

 

    // actually append virtual node to DOM tree

    toDataContainer.appendChild(newNode);

    }

  }

 

// error message for missing selection

function selectionError()

  {alert("Must select something!")}

</script>

<table border="0" class="ordered-selection-field">

  <tr>

    <td>

      <select id="form.data_types.from"

              name="form.data_types.from" size="5"

              multiple="">

        <option value="2be858dafefeebdb71643a221075c81a">Inverse Directions</option>

      </select>

    </td>

    <td>

      <button name="from2toButton" type="button"

              value=" -&gt;"

              onclick="javascript:from2to('form.data_types')">&nbsp;-&gt;</button>

      <br />

      <button name="to2fromButton" type="button"

              value="&lt;- "

              onclick="javascript:to2from('form.data_types')">&lt;-&nbsp;</button>

    </td>

    <td>

      <select id="form.data_types.to"

              name="form.data_types.to" size="5" multiple="">

      </select>

      <input name="form.data_types-empty-marker"

             type="hidden" />

      <span id="form.data_types.toDataContainer">

        <script type="text/javascript">

          copyDataForSubmit('form.data_types');</script>

      </span>

    </td>

    <td>

      <button name="upButton" type="button" value="^"

              onclick="javascript:moveUp('form.data_types')">^</button>

      <br />

      <button name="downButton" type="button" value="v"

              onclick="javascript:moveDown('form.data_types')">v</button>

    </td>

  </tr>

</table>

</div>

          </td>

        </tr>

        <tr>

          <td class="label">

            <label for="form.data_format">

              <span>Data Format</span>

            </label>

           </td>

          <td class="field">

            <div class="widget"><div>

<div class="value">

<select id="form.data_format" name="form.data_format" size="1" >

<option value="3501bb093d363810b671059b9cfed3f8">XML</option>

<option value="cc8d68c551c4a9a6d5313e07de4deafd">CSV</option>

</select>

</div>

<input name="form.data_format-empty-marker" type="hidden" value="1" />

</div></div>

           </td>

        </tr>

         <tr>

          <td class="label">

            <label for="form.file">

              <span class="required">*</span><span>Candidate File</span>

            </label>

           </td>

          <td class="field">

            <div class="widget"><input class="hiddenType" id="form.file.used" name="form.file.used" type="hidden" value="" /> <input class="fileType" id="form.file" name="form.file" size="20" type="file"  /></div>

           </td>

        </tr>

         <tr>

          <td class="label">

            <label for="form.platform">

              <span>Hardware Platform</span>

            </label>

           </td>

          <td class="field">

            <div class="widget"><div>

<div class="value">

<select id="form.platform" name="form.platform" size="1" >

<option value="0x0858">win32</option>

<option value="0x085f">win64</option>

</select>

</div>

<input name="form.platform-empty-marker" type="hidden" value="1" />

</div></div>

           </td>

        </tr>

         <tr>

          <td class="label">

            <label for="form.board">

              <span class="required">*</span><span>hardware ID</span>

            </label>

          </td>

          <td class="field">

            <div class="widget"><input class="textType" id="form.board" name="form.board" size="20" type="text" value=""  /></div>

          </td>

        </tr>

    </tbody>

  </table>

  <div id="actionsView">

    <span class="actionButtons">

      <input type="submit" id="form.actions.4164642043616e646964617465" name="form.actions.4164642043616e646964617465" value="Add Candidate" class="button" />

    </span>

  </div>

</form>

</body>



_______________________________________________
Grok-dev mailing list
Grok-dev@...
https://mail.zope.org/mailman/listinfo/grok-dev

Re: Help on functional doctest for List component

by Christian Klinger :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi Kris:

please try this for DataType(s):

 >>> browser.getControl(‘YOURDATATYPE_Field’).value = ['YourValue',]

and try this for your DateFormat

 >>> browser.getControl(‘YOURDATAFORMAT_FIELD’).value = 'XML'

Ok please give me a note if this works.
If not show me your FormCode and your Interface. Then i will test it here

Hope This Helps

Christian


> Dear Christian,
>
> Underneath a screen shot of the “Add Candidate” form that I want to test
> in the zope testbrowser through a doctest file.
>
> In this doctest file I would like to fill in or make a selection for
> each control and press the “Add Candidate” button.
>
>  >>> browser.getControl(‘Video’).selected = True
>
> Here I don’t know how to make a selection for the “*Data Type(s)”???
>
>> >> browser.getControl('Data Format').getControl('XML').selected = True
>
>> >> import cStringIO
>
>> >> browser.getControl('Candidate
> File').add_file(cStringIO.StringIO('Candidate file
> contents'),'application/_octet_-stream','C:\\_Temp_\Candidate.log')
>
>> >> browser.getControl('Hardware Platform').getControl('win32').selected
> = True
>
>> >> browser.getControl('*hardware ID').value = '_Offline_'
>
> After the screen shot is my HTML
>
> Thanks anyway,
>
> Kris Degryse
>
> <body>
>
> <form
> action="http://localhost:8080/arts/Products/VIP-T/V2.09/ResultGroup1/addcandidate"
>
> method="post" class="edit-form"
>
> enctype="multipart/form-data">
>
> <table class="form-fields">
>
> <tbody>
>
> <tr>
>
> <td class="label">
>
> <label for="form.video">
>
> <span>Video</span>
>
> </label>
>
> </td>
>
> <td class="field">
>
> <div class="widget"><div>
>
> <div class="value">
>
> <select id="form.video" name="form.video" size="1" >
>
> <option value="0x086c">Video</option>
>
> </select>
>
> </div>
>
> <input name="form.video-empty-marker" type="hidden" value="1" />
>
> </div></div>
>
> </td>
>
> </tr>
>
> <tr>
>
> <td class="label">
>
> <label for="form.data_types">
>
> <span class="required">*</span><span>Data Type(s)</span>
>
> </label>
>
> </td>
>
> <td class="field">
>
> <div class="widget"><script type="text/javascript">
>
> function moveItems(from, to)
>
> {
>
> // shortcuts for selection fields
>
> var src = document.getElementById(from);
>
> var tgt = document.getElementById(to);
>
> if (src.selectedIndex == -1) selectionError();
>
> else
>
> {
>
> // iterate over all selected items
>
> // --> attribute "selectedIndex" doesn't support multiple selection.
>
> // Anyway, it works here, as a moved item isn't selected anymore,
>
> // thus "selectedIndex" indicating the "next" selected item :)
>
> while (src.selectedIndex > -1)
>
> if (src.options[src.selectedIndex].selected)
>
> {
>
> // create a new virtal object with values of item to copy
>
> temp = new Option(src.options[src.selectedIndex].text,
>
> src.options[src.selectedIndex].value);
>
> // append virtual object to targe
>
> tgt.options[tgt.length] = temp;
>
> // want to select newly created item
>
> temp.selected = true;
>
> // delete moved item in source
>
> src.options[src.selectedIndex] = null;
>
> }
>
> }
>
> }
>
> // move item from "from" selection to "to" selection
>
> function from2to(name)
>
> {
>
> moveItems(name+".from", name+".to");
>
> copyDataForSubmit(name);
>
> }
>
> // move item from "to" selection back to "from" selection
>
> function to2from(name)
>
> {
>
> moveItems(name+".to", name+".from");
>
> copyDataForSubmit(name);
>
> }
>
> function swapFields(a, b)
>
> {
>
> // swap text
>
> var temp = a.text;
>
> a.text = b.text;
>
> b.text = temp;
>
> // swap value
>
> temp = a.value;
>
> a.value = b.value;
>
> b.value = temp;
>
> // swap selection
>
> temp = a.selected;
>
> a.selected = b.selected;
>
> b.selected = temp;
>
> }
>
> // move selected item in "to" selection one up
>
> function moveUp(name)
>
> {
>
> // shortcuts for selection field
>
> var toSel = document.getElementById(name+".to");
>
> if (toSel.selectedIndex == -1)
>
> selectionError();
>
> else if (toSel.options[0].selected)
>
> alert("Cannot move further up!");
>
> else for (var i = 0; i < toSel.length; i++)
>
> if (toSel.options[i].selected)
>
> {
>
> swapFields(toSel.options[i-1], toSel.options[i]);
>
> copyDataForSubmit(name);
>
> }
>
> }
>
> // move selected item in "to" selection one down
>
> function moveDown(name)
>
> {
>
> // shortcuts for selection field
>
> var toSel = document.getElementById(name+".to");
>
> if (toSel.selectedIndex == -1) {
>
> selectionError();
>
> } else if (toSel.options[toSel.length-1].selected) {
>
> alert("Cannot move further down!");
>
> } else {
>
> for (var i = toSel.length-1; i >= 0; i--) {
>
> if (toSel.options[i].selected) {
>
> swapFields(toSel.options[i+1], toSel.options[i]);
>
> }
>
> }
>
> copyDataForSubmit(name);
>
> }
>
> }
>
> // copy each item of "toSel" into one hidden input field
>
> function copyDataForSubmit(name)
>
> {
>
> // shortcuts for selection field and hidden data field
>
> var toSel = document.getElementById(name+".to");
>
> var toDataContainer = document.getElementById(name+".toDataContainer");
>
> // delete all child nodes (--> complete content) of "toDataContainer" span
>
> while (toDataContainer.hasChildNodes())
>
> toDataContainer.removeChild(toDataContainer.firstChild);
>
> // create new hidden input fields - one for each selection item of
>
> // "to" selection
>
> for (var i = 0; i < toSel.options.length; i++)
>
> {
>
> // create virtual node with suitable attributes
>
> var newNode = document.createElement("input");
>
> var newAttr = document.createAttribute("name");
>
> newAttr.nodeValue = name;
>
> newNode.setAttributeNode(newAttr);
>
> newAttr = document.createAttribute("type");
>
> newAttr.nodeValue = "hidden";
>
> newNode.setAttributeNode(newAttr);
>
> newAttr = document.createAttribute("value");
>
> newAttr.nodeValue = toSel.options[i].value;
>
> newNode.setAttributeNode(newAttr);
>
> // actually append virtual node to DOM tree
>
> toDataContainer.appendChild(newNode);
>
> }
>
> }
>
> // error message for missing selection
>
> function selectionError()
>
> {alert("Must select something!")}
>
> </script>
>
> <table border="0" class="ordered-selection-field">
>
> <tr>
>
> <td>
>
> <select id="form.data_types.from"
>
> name="form.data_types.from" size="5"
>
> multiple="">
>
> <option value="2be858dafefeebdb71643a221075c81a">Inverse Directions</option>
>
> </select>
>
> </td>
>
> <td>
>
> <button name="from2toButton" type="button"
>
> value=" ->"
>
> onclick="javascript:from2to('form.data_types')"> -></button>
>
> <br />
>
> <button name="to2fromButton" type="button"
>
> value="<- "
>
> onclick="javascript:to2from('form.data_types')"><- </button>
>
> </td>
>
> <td>
>
> <select id="form.data_types.to"
>
> name="form.data_types.to" size="5" multiple="">
>
> </select>
>
> <input name="form.data_types-empty-marker"
>
> type="hidden" />
>
> <span id="form.data_types.toDataContainer">
>
> <script type="text/javascript">
>
> copyDataForSubmit('form.data_types');</script>
>
> </span>
>
> </td>
>
> <td>
>
> <button name="upButton" type="button" value="^"
>
> onclick="javascript:moveUp('form.data_types')">^</button>
>
> <br />
>
> <button name="downButton" type="button" value="v"
>
> onclick="javascript:moveDown('form.data_types')">v</button>
>
> </td>
>
> </tr>
>
> </table>
>
> </div>
>
> </td>
>
> </tr>
>
> <tr>
>
> <td class="label">
>
> <label for="form.data_format">
>
> <span>Data Format</span>
>
> </label>
>
> </td>
>
> <td class="field">
>
> <div class="widget"><div>
>
> <div class="value">
>
> <select id="form.data_format" name="form.data_format" size="1" >
>
> <option value="3501bb093d363810b671059b9cfed3f8">XML</option>
>
> <option value="cc8d68c551c4a9a6d5313e07de4deafd">CSV</option>
>
> </select>
>
> </div>
>
> <input name="form.data_format-empty-marker" type="hidden" value="1" />
>
> </div></div>
>
> </td>
>
> </tr>
>
> <tr>
>
> <td class="label">
>
> <label for="form.file">
>
> <span class="required">*</span><span>Candidate File</span>
>
> </label>
>
> </td>
>
> <td class="field">
>
> <div class="widget"><input class="hiddenType" id="form.file.used"
> name="form.file.used" type="hidden" value="" /> <input class="fileType"
> id="form.file" name="form.file" size="20" type="file" /></div>
>
> </td>
>
> </tr>
>
> <tr>
>
> <td class="label">
>
> <label for="form.platform">
>
> <span>Hardware Platform</span>
>
> </label>
>
> </td>
>
> <td class="field">
>
> <div class="widget"><div>
>
> <div class="value">
>
> <select id="form.platform" name="form.platform" size="1" >
>
> <option value="0x0858">win32</option>
>
> <option value="0x085f">win64</option>
>
> </select>
>
> </div>
>
> <input name="form.platform-empty-marker" type="hidden" value="1" />
>
> </div></div>
>
> </td>
>
> </tr>
>
> <tr>
>
> <td class="label">
>
> <label for="form.board">
>
> <span class="required">*</span><span>hardware ID</span>
>
> </label>
>
> </td>
>
> <td class="field">
>
> <div class="widget"><input class="textType" id="form.board"
> name="form.board" size="20" type="text" value="" /></div>
>
> </td>
>
> </tr>
>
> </tbody>
>
> </table>
>
> <div id="actionsView">
>
> <span class="actionButtons">
>
> <input type="submit" id="form.actions.4164642043616e646964617465"
> name="form.actions.4164642043616e646964617465" value="Add Candidate"
> class="button" />
>
> </span>
>
> </div>
>
> </form>
>
> </body>
>
>
>
> _______________________________________________
> Grok-dev mailing list
> Grok-dev@...
> https://mail.zope.org/mailman/listinfo/grok-dev


_______________________________________________
Grok-dev mailing list
Grok-dev@...
https://mail.zope.org/mailman/listinfo/grok-dev

Parent Message unknown Re: Help on functional doctest for List component

by Kris Degryse-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Some parts of this message have been removed. Learn more about Nabble's security policy.

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@...
https://mail.zope.org/mailman/listinfo/grok-dev

Re: Help on functional doctest for List component

by Christian Klinger :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

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@...
> https://mail.zope.org/mailman/listinfo/grok-dev


_______________________________________________
Grok-dev mailing list
Grok-dev@...
https://mail.zope.org/mailman/listinfo/grok-dev