Georeferencing.txt
==================

Initialize the test browser

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

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 = []

Create a test document

    >>> folder = self.folder
    >>> folder.setDescription('The testing folder')
    >>> folder.invokeFactory('Document', id='document')
    'document'
    >>> document = folder.document
    >>> from Products.PleiadesGeocoder.interfaces import IGeoAnnotatableContent
    >>> IGeoAnnotatableContent.providedBy(document)
    True

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

Then georeference the document via the edit_geo form

    >>> browser.mech_browser.set_handle_redirect(False)
    >>> from urllib2 import HTTPError
    >>> doc_url = document.absolute_url()
    >>> try:
    ...     browser.open("%s/@@edit_geo?type=Point&coordinates=[-110,40]" % doc_url)
    ... except HTTPError, exc:
    ...     print str(exc)
    ...     print exc.headers.getheader('Location')
    HTTP Error 302: Moved Temporarily
    localhost?portal_status_message=Changes%20saved.

Confirm new geo location

    >>> from Products.PleiadesGeocoder.interfaces import IGeoItemSimple
    >>> item = IGeoItemSimple(document)
    >>> item.__geo_interface__
    {'geometry': {'type': 'Point', 'coordinates': (-110.0, 40.0, 0.0)}, 'id': 'document', 'properties': {'link': 'http://nohost/plone/Members/test_user_1_/document', 'description': '', 'title': 'document'}}

    
