collective.geo.kml openlayers
=============================

Overview
--------
kmlopenlayersview is a BrowserView showing an openlayers map for folderish content.
The map will show all geo referenced objects in that folderish object.


Folder test
-----------

We start the tests with the usual boilerplate
    >>> from plone.testing.z2 import Browser
    >>> browser = Browser(layer['app'])
    >>> portal = layer['portal']
    >>> portal_url = portal.absolute_url()
    >>> portal.error_log._ignored_exceptions = ()


we log in for tests
    >>> from plone.app.testing import SITE_OWNER_NAME
    >>> from plone.app.testing import SITE_OWNER_PASSWORD
    >>> browser.addHeader('Authorization',
    ...                   'Basic %s:%s' % (SITE_OWNER_NAME, SITE_OWNER_PASSWORD))


We can set kmlopenlayers view as default view for a Folder
    >>> folder = portal.get('folder')
    >>> folder_url = folder.absolute_url()
    >>> browser.open(folder_url)
    >>> browser.getLink('Kml Openlayers View').click()


Check to see that the byline is visible,
    >>> '<div class="documentByLine" id="plone-document-byline">' in browser.contents
    True

the description is visible,
    >>> '<p class="documentDescription">' in browser.contents
    True

In this view we can see a div that contains the openlayers map
    >>> '<div id="default-cgmap" class="widget-cgmap"' in browser.contents
    True


Kml map layer javascript
    >>> "var layer=new OpenLayers.Layer.Vector('%s'" % \
    ... folder.Title() in browser.contents
    True

and 'Download KML' link
    >>> browser.getLink('Download KML')
    <Link text='Download KML' url='...@@kml-document'>

We can also check to see if we're able to view the KML view without it being
our default folder view.  First, we reset our view back a standard folder
view.

    >>> browser.open(folder_url)
    >>> browser.getLink('Standard view').click()

Now, we try and load the KML view without setting it as default

    >>> browser.open(folder_url+'/kml-openlayers')

Finally, we can see a div that contains the openlayers map
    >>> '<div id="default-cgmap" class="widget-cgmap"' in browser.contents
    True


Topic (old) test
----------------

The openlayers view can be enabled also for Topic. We have a Topic in portal root for testing that
    >>> topic = folder['topic']
    >>> topic_url = topic.absolute_url()
    >>> browser.open(topic_url)
    >>> browser.getLink('Kml Openlayers View').click()

Check to make sure the map div appears fine
    >>> '<div id="default-cgmap" class="widget-cgmap"' in browser.contents
    True

also Kml map layer javascript will appear
    >>> "var layer=new OpenLayers.Layer.Vector('%s'" % \
    ... topic.Title() in browser.contents
    True

and also 'Download KML' link
    >>> browser.getLink('Download KML')
    <Link text='Download KML' url='...@@kml-document'>


Collection test
---------------

The openlayers view can be enabled also for Topic. We have a Topic in portal root for testing that
    >>> collection = folder['collection']
    >>> collection_url = collection.absolute_url()
    >>> browser.open(collection_url)
    >>> browser.getLink('Kml Openlayers View').click()

Check to make sure the map div appears fine
    >>> '<div id="default-cgmap" class="widget-cgmap"' in browser.contents
    True

also Kml map layer javascript will appear
    >>> "var layer=new OpenLayers.Layer.Vector('%s'" % \
    ... collection.Title() in browser.contents
    True

and also 'Download KML' link
    >>> browser.getLink('Download KML')
    <Link text='Download KML' url='...@@kml-document'>
