.. -*-doctest-*-

=================
Sites Using Plone
=================

Start with a portal.

    >>> from Products.PloneServicesCenter import testing
    >>> app = testing.SERVICES_FUNCTIONAL_TESTING['app']
    >>> portal = testing.SERVICES_FUNCTIONAL_TESTING['portal']

Open a browser and log in as a user who can add content.

    >>> from plone.testing import z2
    >>> browser = z2.Browser(app)
    >>> browser.handleErrors = False
    >>> browser.open(portal.absolute_url())

    >>> browser.getLink('Log in').click()
    >>> browser.getControl('Login Name').value = 'test-user'
    >>> browser.getControl('Password').value = 'secret'
    >>> browser.getControl('Log in').click()
    >>> print browser.contents
    <...You are now logged in...

Go to the sites folder and add a site using plone inside.

    >>> browser.open(portal.support.sites.absolute_url())
    >>> browser.getLink(url='createObject?type_name=SiteUsingPlone').click()
    >>> browser.getControl('Title').value = 'Foo Site Using Plone Title'
    >>> browser.getControl('Description').value = (
    ...     'Foo Site Using Plone Description')
    >>> browser.getControl('United Kingdom').selected = True
    >>> browser.getControl('Transportation and Logistics').selected = True
    >>> browser.getControl('URL').value = 'http://foo.example.com'
    >>> browser.getControl('Save').click()
    >>> print browser.contents
    <...
                <dd>Changes saved.</dd>...
    >>> browser.url
    'http://nohost/plone/support/sites/foo-site-using-plone-title'
    >>> portal.support.sites.contentValues()
    [<SiteUsingPlone at /plone/support/sites/foo-site-using-plone-title>]
    >>> site = portal.support.sites['foo-site-using-plone-title']

Tolerate uppercase country codes.

    >>> z2.login(app.acl_users, 'admin')
    >>> site.update(country=site.getCountry().upper())
    >>> import transaction
    >>> transaction.commit()

After the site is now visible on the listing.

    >>> browser.open(portal.support.sites.absolute_url())
    >>> print browser.contents
    <...Foo Site Using Plone Title...
    ...Foo Site Using Plone Description...

The countries are selectable by the human readable country name.

    >>> browser.getControl('United Kingdom').selected = True
    >>> browser.getControl('Filter').click()
    >>> print browser.contents
    <...Foo Site Using Plone Title...
    ...Foo Site Using Plone Description...

The listing is a clickable link which takes the user to the item.

    >>> browser.getLink('Foo Site Using Plone Title').click()
    >>> print browser.contents
    <...Foo Site Using Plone Title...
    ...Foo Site Using Plone Description...
    ...http://foo.example.com...
    >>> browser.url
    'http://nohost/plone/support/sites/foo-site-using-plone-title'

The description is only shown twice, once in the <head> and once in
the <body>.

    >>> browser.contents.count('Foo Site Using Plone Description')
    2

The industry and country links to the folder view with the appropriate
filter.

    >>> browser.getLink('Transportation and Logistics')
    <Link text='Transportation and Logistics'
    url='http://nohost/plone/support/sites?industries:list=Transportation%20and%20Logistics'>
    >>> browser.getLink('United Kingdom')
    <Link text='United Kingdom'
    url='http://nohost/plone/support/sites?countries:list=gb'>
