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

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.enable_sitemap').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

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

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

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
