
Setting up some Content
-------------------------

We use zope.testbrowser to simulate browser interaction in order to show
the main flow of pages. This is not a true functional test, because we also
inspect and modify the internal state of the ZODB, but it is a useful way of
making sure we test the full end-to-end process of creating and modifying
content.

    >>> from plone.testing.z2 import Browser
    >>> from plone.app.testing import SITE_OWNER_NAME, SITE_OWNER_PASSWORD

    >>> browser = Browser(layer['app'])
    >>> portal = layer['portal']
    >>> portal_url = portal.absolute_url()
    >>> portal_url
    'http://nohost/plone'


The following is useful when writing and debugging testbrowser tests. It lets
us see error messages properly.

    >>> browser.handleErrors = False
    >>> portal.error_log._ignored_exceptions = ()


Firs we create the demo structure to test if all content types work as exspected.
We have to login as portal owner

    >>> login_url = portal_url + '/login_form'
    >>> browser.open(login_url)

We have the login portlet, so let's use that.

    >>> browser.getControl(name='__ac_name').value = SITE_OWNER_NAME
    >>> browser.getControl(name='__ac_password').value = SITE_OWNER_PASSWORD
    >>> browser.getControl(name='submit').click()


Create some simplelayout contents

    >>> browser.open(portal_url + '/createObject?type_name=Page')
    >>> browser.getControl('Title',index=0).value="a sl page"
    >>> browser.getControl('Save').click()
    >>> 'a sl page' in browser.contents
    True
