================
Functional tests
================

  >>> from zope.testbrowser.testing import Browser
  >>> browser = Browser()
  >>> browser.addHeader('Authorization','Basic mgr:mgrpw')
  >>> browser.handleErrors = False

  >>> browser.open('http://localhost/@@managesamples.html')
  >>> browser.getLink(text='ice.adverlet.test').click()
  >>> browser.getControl(name='z3c.sampledata.site.sitename').value = 'adverlets'
  >>> browser.getControl('Generate').click()

Management UI
-------------

  >>> management_url = 'http://localhost/manage-adverlets.html'
  >>> browser.open(management_url)
  >>> browser.headers['STATUS']
  '200 Ok'

  >>> browser.getLink(url=management_url+'?custom=footer')
  <Link text='...' url='...'>

  >>> browser.getLink(url=management_url+'?preview=footer')
  <Link text='...' url='...'>

  >>> browser.getLink(url=management_url+'?settings=yes')
  <Link text='...' url='...'>

  >>> browser.getLink(url=management_url+'?info=yes')
  <Link text='...' url='...'>

  >>> browser.getLink(url=management_url+'?images=yes')
  <Link text='...' url='...'>

  >>> browser.getLink(url=management_url+'?undo=yes')
  <Link text='...' url='...'>

  >>> browser.getLink(url=management_url+'?help=yes')
  <Link text='...' url='...'>

Edit adverlet::

  >>> browser.open(management_url+'?custom=footer')
  >>> browser.headers['STATUS']
  '200 Ok'

  >>> browser.getControl('Close').click()
  >>> browser.url
  'http://localhost/manage-adverlets.html'

  >>> browser.open(management_url+'?custom=footer')
  >>> browser.getControl('HTML Source').value = '<h6>FOOTER TEXT</h6>'
  >>> browser.getControl('Apply').click()

  >>> browser.headers['STATUS']
  '200 Ok'

  >>> browser.url
  'http://localhost/manage-adverlets.html?custom=footer'

Check new adverlet::

  >>> '<h6>FOOTER TEXT</h6>' in browser.contents
  True

Preview adverlet::

  >>> browser.open(management_url+'?preview=footer')
  >>> browser.headers['STATUS']
  '200 Ok'

  >>> '<div class="preview-adverlet"><h6>FOOTER TEXT</h6></div>' in browser.contents
  True

Settings::

  >>> browser.open(management_url+'?settings=yes')
  >>> browser.headers['STATUS']
  '200 Ok'

  >>> browser.getControl('Close').click()
  >>> browser.url
  'http://localhost/manage-adverlets.html'

Info::

  >>> browser.open(management_url+'?info=yes')
  >>> browser.headers['STATUS']
  '200 Ok'

  >>> '<span>Size of sources:</span>\n    <span>20</span>\n    <span>bytes.</span>' in browser.contents
  True
  >>> '<span>Size of images:</span>\n    <span>0</span>\n    <span>bytes.</span>' in browser.contents
  True

Upload::

  >>> browser.open(management_url+'?images=yes')
  >>> browser.headers['STATUS']
  '200 Ok'

  >>> browser.getControl('Close').click()
  >>> browser.url
  'http://localhost/manage-adverlets.html'

Undo::

  >>> browser.open(management_url+'?undo=yes')
  >>> browser.headers['STATUS']
  '200 Ok'

  >>> '<th>Undo</th>' in browser.contents
  True

Help::

  >>> browser.open(management_url+'?help=yes')
  >>> browser.headers['STATUS']
  '200 Ok'

  >>> '<div class="help-adverlets">' in browser.contents
  True
