Overview
========

This is a doctest designed to test that events are handled as expected.

Initial setup: login, and do necessary imports.

    >>> from zope import event
    >>> from zope.interface import alsoProvides
    >>> from zope.app.container.contained import ObjectAddedEvent
    >>> from zope.app.container.contained import ObjectRemovedEvent
    >>> from zope.lifecycleevent import ObjectModifiedEvent
    >>> from slc.publications.interfaces import IPublicationEnhanced
    >>> from slc.publications.interfaces import IPublicationContainerEnhanced

1. Test that uploaded files are subtyped to IPublicationEnhanced.

    >>> alsoProvides(folder, IPublicationContainerEnhanced)
    >>> fid = folder.invokeFactory('File', 'mypub')
    >>> file = getattr(folder, fid)
    >>> f = loadfile('doc/UsingthePublicationProduct.pdf')
    >>> file.setFile(f)
    >>> event.notify(ObjectAddedEvent(folder, file))

    >>> file = folder._getOb('mypub')
    >>> IPublicationEnhanced.providedBy(file)
    True

2. Test that the data folder is created.

It's worth noting here that the data folder gets created in a surprising way:

adapters.events.ChapterUpdater is the event handler registered for
IObjectModifiedEvent. The __init__ method calls _manage_chapters which
calls utils._get_storage_folder which creates the folder.

    >>> event.notify(ObjectModifiedEvent(file))
    >>> folder.objectIds()
    ['mypub', 'mypub_data']

3. Test that with deleted files, the data folder is also deleted.

    >>> folder.manage_delObjects(['mypub'])
    >>> folder.objectIds()
    []

