Site control panel
==================

First some initial setup code:

    >>> from zope.component import getUtility
    >>> from Products.CMFCore.interfaces import IPropertiesTool
    >>> ptool = getUtility(IPropertiesTool)
    >>> self.loginAsManager()

    >>> ptool.site_properties.enable_sitemap
    False
    
    >>> ptool.site_properties.displayPublicationDateInByline
    False

Viewing the site control panel
-----------------------------

    >>> self.browser.open('http://nohost/plone/@@site-controlpanel')
    >>> self.browser.url
    'http://nohost/plone/@@site-controlpanel'

Click the cancel button:

    >>> self.browser.getControl(name="form.actions.cancel").click()
    >>> self.browser.url.endswith('plone_control_panel')
    True

There should be still no changes:

    >>> 'Changes canceled.' in self.browser.contents
    True

Make some changes
-----------------

    >>> self.browser.open('http://nohost/plone/@@site-controlpanel')
    >>> self.browser.url.endswith('site-controlpanel')
    True

    >>> self.browser.getControl(name='form.site_title').value = "Site"
    >>> self.browser.getControl(name='form.enable_sitemap').value = True
    >>> self.browser.getControl(name='form.display_pub_date_in_byline').value = True

Click the save button:

    >>> self.browser.getControl(name="form.actions.save").click()
    >>> self.browser.url.endswith('site-controlpanel')
    True

We should be informed that something has changed:

    >>> 'Changes saved.' in self.browser.contents
    True

Make sure the changes have been applied correctly to the tool:

    >>> ptool.site_properties.enable_sitemap
    True
    >>> ptool.site_properties.displayPublicationDateInByline
    True

Test if the sitemaps does appear:

    >>> self.browser.open("http://nohost/plone/sitemap.xml.gz")
    >>> headers = self.browser.headers

    >>> headers['status'].lower()
    '200 ok'

    >>> headers['content-type']
    'application/octet-stream'

Make again some changes
-----------------------

    >>> self.browser.open('http://nohost/plone/@@site-controlpanel')
    >>> self.browser.url.endswith('site-controlpanel')
    True

    >>> self.browser.getControl(name='form.enable_sitemap').value = False
    >>> self.browser.getControl(name='form.display_pub_date_in_byline').value = False

Click the save button:

    >>> self.browser.getControl(name="form.actions.save").click()
    >>> self.browser.url.endswith('site-controlpanel')
    True

We should be informed that something has changed:

    >>> 'Changes saved.' in self.browser.contents
    True

Make sure the changes have been applied correctly to the tool:

    >>> ptool.site_properties.enable_sitemap
    False
    >>> ptool.site_properties.displayPublicationDateInByline
    False

Check the sitemap actually, should raise a 404:

    >>> self.browser.handleErrors = True
    >>> from zope.publisher.interfaces import NotFound
    >>> from urllib2 import HTTPError
    >>> try:
    ...     self.browser.open("http://nohost/plone/sitemap.xml.gz")
    ... except HTTPError, e:
    ...     if e.code == 404:
    ...         print "ok"
    ok


Test the DC properties
----------------------

    >>> self.browser.open('http://nohost/plone/@@site-controlpanel')
    >>> self.browser.url.endswith('site-controlpanel')
    True

    >>> self.browser.getControl(name='form.exposeDCMetaTags').value = True

Click the save button:

    >>> self.browser.getControl(name="form.actions.save").click()
    >>> self.browser.url.endswith('site-controlpanel')
    True

We should be informed that something has changed:

    >>> 'Changes saved.' in self.browser.contents
    True

Make sure the changes have been applied correctly to the tool:

    >>> ptool.site_properties.exposeDCMetaTags
    True

Test if DC meta tags are exposed:

    >>> self.browser.open("http://nohost/plone/")
    >>> 'DC.type' in self.browser.contents
    True
