    ============
    J01form test
    ============

    The testbrowser package provides built-in support for testing j01.jsonrpc and
    j01form components. This means a request get submitted by JSON-RPC and the
    content get partial replaced based on the target expression given from the
    repsonse.

    from __future__ import absolute_import
    from __future__ import print_function
      >>> from p01.testbrowser.testing import getWSGITestBrowser
      >>> from p01.testbrowser.ftests.wsgitestapp import WSGITestApplication

    Setup the wsgi test application:

      >>> wsgi_app = WSGITestApplication()

    Let's setup the demo app and get a j01 form:

      >>> url = 'http://localhost/j01form.html'
      >>> browser = getWSGITestBrowser(url, wsgi_app=wsgi_app)

    Check the page content:

      >>> print((browser.contents))

# J01Form Test

Text 1 Text 2
No Content
    We can get the input control:

      >>> control = browser.getControl(name='text1')
      >>> control
      >>> control.value
      'Text 1'

      >>> control = browser.getControl(name='text2')
      >>> control
      >>> control.value
      'Text 2'

    set a value:

      >>> control = browser.getControl(name='text1')
      >>> control.value = 'value'
      >>> control.value
      'value'

    and submit the form with a simple POST request (non json-rpc):

      >>> browser.getControl(name='submit').click()

      browser.getControl(name='text1').value
      'value'

    Check the page content. As you can see, the text1 value is our posted value:

      >>> print((browser.contents))

# J01Form Test

Text 1 Text 2
No Content
    json-rpc and controls
    ---------------------

    An important part is, that if j01.jsonrpc submits a form with json.rpc and
    replaces the content, other not replaced content must stay as is. This works
    as shown in test above.

    Another important part is, that if we submit and replace partial content in the
    dom, that previous filled controls based on content that didn't get replaces by
    the response content must also stay as is. Otherwise we could loose previous
    filled control values if we replace the dom.

    In other words on each request, we will replace the browser content and reset
    some browser internal markers. On json-rpc request we must make sure that
    the control values must survive for the form that doesn't get replaced.
    Let's thest this:

      >>> url = 'http://localhost/j01form.html'
      >>> browser = getWSGITestBrowser(url, wsgi_app=wsgi_app)

    first, load the content into the right div:

      >>> browser.getControl(name='load').click()

    Fill in all control values:

      >>> browser.getControl(name='text1').value = 'V1'
      >>> browser.getControl(name='text2').value = 'V2'
      >>> browser.getControl(name='text3').value = 'V3'
      >>> browser.getControl(name='text4').value = 'V4'

    Submit the right form. This will replace the right form with a status message
    and the left form input fields will stay as is:

      >>> browser.getControl(name='save').click()

    As you can see the control values for text1 and text2 are still there:

      >>> browser.getControl(name='text1').value
      'V1'

      >>> browser.getControl(name='text2').value
      'V2'

    And the controls text3 and text4 in the right div get replaced with the form
    status message:

    And we also dumped the new control value to the dom:

      >>> print(browser.contents)

# J01Form Test

Text 1 Text 2
Form saved