Sitemap testing
===============

First some initial setup code:

    >>> self.loginAsManager()

There is a site property which controls accesso to the sitemap. This defaults
to off, since generating the sitemap is an expensive operation which can
easily lead to denial of service attack.

    >>> self.portal.portal_properties.site_properties.getProperty("enable_sitemap")
    False


Disabled sitemap
----------------

Trying to download the sitemap while it is not enabled results in an error:

    >>> self.browser.open('http://nohost/plone/sitemap.xml.gz')
    Traceback (most recent call last):
    ...
    HTTPError: HTTP Error 404: Not Found


Obtain the sitemap
------------------

To test the sitemap we first need to enable it:

    >>> self.portal.portal_properties.site_properties.manage_changeProperties(enable_sitemap=True)

we can now open the sitemap:

    >>> self.browser.open('http://nohost/plone/sitemap.xml.gz')
    >>> self.browser.url
    'http://nohost/plone/sitemap.xml.gz'

Get the contents and decode them
    >>> data = self.browser.contents
    >>> from gzip import GzipFile
    >>> from StringIO import StringIO
    >>> sio = StringIO(data)
    >>> fp = GzipFile(fileobj=sio)
    >>> xml = fp.read()
    >>> fp.close()

Not sure how to test the XML now as it also contains dates but for now
we will just search for some URLs and tags.

    >>> xml.find('<loc>http://nohost/plone/Members/test_user_1_</loc>')!=-1
    True
    >>> xml.find('<loc>http://nohost/plone/front-page</loc>')!=-1
    True
