Test portlets
=============

We want to test some portlets.  We need some test requests for that.
A request needs to be annotatable as we use memoize.

    >>> from zope.publisher.browser import TestRequest
    >>> from zope.annotation.interfaces import IAttributeAnnotatable
    >>> from zope.interface import classImplements
    >>> classImplements(TestRequest, IAttributeAnnotatable)

Currently there is one Project, but we do not have any tasks assigned
to us there.

    >>> from urllib import unquote
    >>> def physicalPathFromURL(self, URL):
    ...     # Simplified version of ZPublisher.HTTPRequest.py
    ...     path = filter(None, URL.split( '/'))
    ...     if URL.find( '://') >= 0:
    ...         path = path[2:]
    ...     return map(unquote, path)
    >>> TestRequest.physicalPathFromURL = physicalPathFromURL
    >>> len(self.catalog(portal_type='Project'))
    1
    >>> len(self.catalog(portal_type='Task'))
    1
    >>> from Products.eXtremeManagement.browser.projects import MyProjects
    >>> myprojects = MyProjects(self.portal, TestRequest())
    >>> myprojects.projectlist
    []

Now we add ourselves and another employee to the assignees of a task
in that project.  Now the portlet should return a result.

    >>> self.task.setAssignees(('employee', self.default_user,))
    >>> self.task.reindexObject()
    >>> myprojects = MyProjects(self.portal, TestRequest())
    >>> myprojects.projectlist
    [<Products.ZCatalog.Catalog.mybrains object at ...>]

