FolderGeoViews.txt
==================

Tests of GeoRSS and KML views of folders and their georeferenced contents.

A lot of this is cribbed from optilude's tutorial on plone.org.

Georeference the test user

    >>> mt = self.portal.portal_membership
    >>> member = mt.getMemberById('test_user_1_')
    >>> member.setMemberProperties(
    ...     {'geometryType':'point',
    ...      'spatialCoordinates':'40.585609 -105.083733 0.0',
    ...      'fullname': 'Test User',
    ...      'description': 'Faceless test user number one'})

Add one doc to the folder, and georeference it

    >>> folder = self.folder
    >>> folder.setDescription('The testing folder')
    >>> folder.invokeFactory('Document', id='document')
    'document'
    >>> document = folder.document
    >>> from Products.PleiadesGeocoder.interfaces import IGeoItemSimple
    >>> item = IGeoItemSimple(document)
    >>> item.setGeoInterface('Point', (-105.083733, 40.585609))
    >>> item.isGeoreferenced()
    True
    
Initialize the test browser

    >>> from Products.Five.testbrowser import Browser
    >>> browser = Browser()
    >>> browser.handleErrors = False

Let us log all exceptions, which is useful for debugging. Also, clear portlet
slots, to make the test browser less confused by things like the recent portlet
and the navtree.

    >>> self.portal.error_log._ignored_exceptions = ()
    >>> self.portal.left_slots = self.portal.right_slots = []

Folder tests
------------

    Get our base url
    
    >>> folder_url = folder.absolute_url()

Login

    >>> try:
    ...     from Products.PloneTestCase.setup import portal_owner, default_password
    ...     portal_url = self.portal.absolute_url()
    ...     browser.open(portal_url)
    ...     browser.getControl(name='__ac_name').value = portal_owner
    ...     browser.getControl(name='__ac_password').value = default_password
    ...     browser.getControl(name='submit').click()
    ... except:
    ...     # login isn't needed with 2.5
    ...     pass

    GeoRSS

    >>> browser.open("%s/georss" % folder_url)
    >>> browser.headers['content-type']
    'application/atom+xml; charset=utf-8'
    >>> print browser.contents
    <?xml...?>
    <feed xmlns="http://www.w3.org/2005/Atom"
          xmlns:georss="http://www.georss.org/georss"
          xmlns:gml="http://www.opengis.net/gml">
    <BLANKLINE>
    <BLANKLINE>
      <title>test_user_1_</title>
      <link rel="self"
            href="http://nohost/plone/Members/test_user_1_"/>
      <updated/>
      <author/>
      <id>http://nohost/plone/Members/test_user_1_</id>
    <BLANKLINE>
      <entry>
        <title>document</title>
        <link rel="alternate"
              href="http://nohost/plone/Members/test_user_1_/document">http://nohost/plone/Members/test_user_1_/document</link>
        <id>http://nohost/plone/Members/test_user_1_/document</id>
        <updated/>
        <summary>None.</summary>
    <BLANKLINE>
    <BLANKLINE>
        <georss:where>
          <gml:Point>
            <gml:pos>40.585609 -105.083733</gml:pos>
          </gml:Point>
        </georss:where>
    <BLANKLINE>
    <BLANKLINE>
    <BLANKLINE>
      </entry>
    </feed>
    <BLANKLINE>
    <BLANKLINE>

Test maxitems=0

    >>> browser.open("%s/georss?maxitems=0" % folder_url)
    >>> print browser.contents
    <?xml...?>
    <feed xmlns="http://www.w3.org/2005/Atom"
          xmlns:georss="http://www.georss.org/georss"
          xmlns:gml="http://www.opengis.net/gml">
    <BLANKLINE>
    <BLANKLINE>
      <title>test_user_1_</title>
      <link rel="self"
            href="http://nohost/plone/Members/test_user_1_"/>
      <updated/>
      <author/>
      <id>http://nohost/plone/Members/test_user_1_</id>
    <BLANKLINE>
    </feed>
    <BLANKLINE>
    <BLANKLINE>

Test the KML 2.1 view

    >>> browser.open("%s/kml" % folder_url)
    >>> 'application/vnd.google-earth.kml+xml; charset=utf-8' in browser.headers['content-type']
    True
    >>> print browser.contents
    <?xml...?>
    <kml xmlns="http://earth.google.com/kml/2.1">
    <BLANKLINE>
    <BLANKLINE>
      <Document>
        <Style id="defaultStyle">
          <LineStyle>
            <color>ffff0000</color>
            <width>2</width>
          </LineStyle>
          <PolyStyle>
            <color>33ff0000</color>
          </PolyStyle>
        </Style>
        <name></name>
        <visibility>0</visibility>
        <open>0</open>
        <Placemark>
          <name>document</name>
    <BLANKLINE>
          <description>
            <![CDATA[
              <div>
                <p></p>
                <p>URL: 
                  <a href="http://nohost/plone/Members/test_user_1_/document">http://nohost/plone/Members/test_user_1_/document</a>
                </p>
              </div>
            ]]>
          </description>
    <BLANKLINE>
          <styleUrl>#defaultStyle</styleUrl>
    <BLANKLINE>
          <Point>
            <coordinates>-105.083733,40.585609,0.000000</coordinates>
          </Point>
    <BLANKLINE>
    <BLANKLINE>
    <BLANKLINE>
        </Placemark>
      </Document>
    </kml>
    <BLANKLINE>
    <BLANKLINE>

    >>> browser.open("%s/nwlink" % folder_url)
    >>> 'application/vnd.google-earth.kml+xml; charset=utf-8' in browser.headers['content-type']
    True
    >>> print browser.contents
    <?xml...?>
    <kml xmlns="http://earth.google.com/kml/2.1">
    <BLANKLINE>
    <BLANKLINE>
      <NetworkLink>
        <name></name>
        <description>The testing folder</description>
          <Link>
            <href>http://nohost/plone/Members/test_user_1_/kml</href>
            <viewRefreshMode>onRequest</viewRefreshMode>
          </Link>
      </NetworkLink>
    </kml>
    <BLANKLINE>
    <BLANKLINE>

Test view of /Members

    >>> browser.open("%s/Members/georss" % self.portal.absolute_url())
    >>> print browser.contents
    <?xml...?>
    <feed xmlns="http://www.w3.org/2005/Atom"
          xmlns:georss="http://www.georss.org/georss"
          xmlns:gml="http://www.opengis.net/gml">
    <BLANKLINE>
    <BLANKLINE>
      <title>...</title>
      <link rel="self" href="http://nohost/plone/Members"/>
      <updated/>
      <author/>
      <id>http://nohost/plone/Members</id>
    <BLANKLINE>
      <entry>
        <title>Test User</title>
        <link rel="alternate"
              href="http://nohost/plone/author/test_user_1_">http://nohost/plone/author/test_user_1_</link>
        <id>http://nohost/plone/author/test_user_1_</id>
        <updated/>
        <summary>Faceless test user number one</summary>
    <BLANKLINE>
    <BLANKLINE>
        <georss:where>
          <gml:Point>
            <gml:pos>40.585609 -105.083733</gml:pos>
          </gml:Point>
        </georss:where>
    <BLANKLINE>
    <BLANKLINE>
    <BLANKLINE>
      </entry>
    </feed>
    <BLANKLINE>
    <BLANKLINE>

    >>> browser.open("%s/Members/kml" % self.portal.absolute_url())
    >>> print browser.contents
    <?xml...?>
    <kml xmlns="http://earth.google.com/kml/2.1">
    <BLANKLINE>
    <BLANKLINE>
      <Document>
        <Style id="defaultStyle">
          <LineStyle>
            <color>ffff0000</color>
            <width>2</width>
          </LineStyle>
          <PolyStyle>
            <color>33ff0000</color>
          </PolyStyle>
        </Style>
        <name>...</name>
        <visibility>0</visibility>
        <open>0</open>
        <Placemark>
          <name>Test User</name>
    <BLANKLINE>
          <description>
            <![CDATA[
              <div>
                <p>Faceless test user number one</p>
                <p>URL: 
                  <a href="http://nohost/plone/author/test_user_1_">http://nohost/plone/author/test_user_1_</a>
                </p>
              </div>
            ]]>
          </description>
    <BLANKLINE>
          <styleUrl>#defaultStyle</styleUrl>
    <BLANKLINE>
          <Point>
            <coordinates>-105.083733,40.585609,0.000000</coordinates>
          </Point>
    <BLANKLINE>
    <BLANKLINE>
    <BLANKLINE>
        </Placemark>
      </Document>
    </kml>
    <BLANKLINE>
    <BLANKLINE>

    >>> browser.open("%s/Members/nwlink" % self.portal.absolute_url())
    >>> print browser.contents
    <?xml...?>
    <kml xmlns="http://earth.google.com/kml/2.1">
    <BLANKLINE>
    <BLANKLINE>
      <NetworkLink>
        <name>...</name>
        <description>Container for ... home directories</description>
          <Link>
            <href>http://nohost/plone/Members/kml</href>
            <viewRefreshMode>onRequest</viewRefreshMode>
          </Link>
      </NetworkLink>
    </kml>
    <BLANKLINE>
    <BLANKLINE>

Test single object

    >>> browser.open("%s/georss" % document.absolute_url())
    >>> print browser.contents
    <?xml...?>
    <feed xmlns="http://www.w3.org/2005/Atom"
          xmlns:georss="http://www.georss.org/georss"
          xmlns:gml="http://www.opengis.net/gml">
    <BLANKLINE>
    <BLANKLINE>
      <title>document</title>
      <link rel="self"
            href="http://nohost/plone/Members/test_user_1_/document"/>
      <updated/>
      <author/>
      <id>http://nohost/plone/Members/test_user_1_/document</id>
    <BLANKLINE>
      <entry>
        <title>document</title>
        <link rel="alternate"
              href="http://nohost/plone/Members/test_user_1_/document">http://nohost/plone/Members/test_user_1_/document</link>
        <id>http://nohost/plone/Members/test_user_1_/document</id>
        <updated/>
        <summary>None.</summary>
    <BLANKLINE>
    <BLANKLINE>
        <georss:where>
          <gml:Point>
            <gml:pos>40.585609 -105.083733</gml:pos>
          </gml:Point>
        </georss:where>
    <BLANKLINE>
    <BLANKLINE>
    <BLANKLINE>
      </entry>
    </feed>
    <BLANKLINE>
    <BLANKLINE>

    >>> browser.open("%s/kml" % document.absolute_url())
    >>> print browser.contents
    <?xml...?>
    <kml xmlns="http://earth.google.com/kml/2.1">
    <BLANKLINE>
    <BLANKLINE>
      <Document>
        <Style id="defaultStyle">
          <LineStyle>
            <color>ffff0000</color>
            <width>2</width>
          </LineStyle>
          <PolyStyle>
            <color>33ff0000</color>
          </PolyStyle>
        </Style>
        <name></name>
        <visibility>0</visibility>
        <open>0</open>
        <Placemark>
          <name>document</name>
    <BLANKLINE>
          <description>
            <![CDATA[
              <div>
                <p></p>
                <p>URL: 
                  <a href="http://nohost/plone/Members/test_user_1_/document">http://nohost/plone/Members/test_user_1_/document</a>
                </p>
              </div>
            ]]>
          </description>
    <BLANKLINE>
          <styleUrl>#defaultStyle</styleUrl>
    <BLANKLINE>
          <Point>
            <coordinates>-105.083733,40.585609,0.000000</coordinates>
          </Point>
    <BLANKLINE>
    <BLANKLINE>
    <BLANKLINE>
        </Placemark>
      </Document>
    </kml>
    <BLANKLINE>
    <BLANKLINE>

