import os, sys
if __name__ == '__main__':
    execfile(os.path.join(sys.path[0], 'framework.py'))

# We need some Five monkey patches in place
import Products.Five

from zope.testing.doctestunit import DocFileSuite
from zope.app.tests import ztapi, placelesssetup
from zope.app.annotation.interfaces import IAnnotations
from zope.app.annotation.interfaces import IAttributeAnnotatable
from zope.app.annotation.attribute import AttributeAnnotations
from OFS.interfaces import IObjectWillBeRemovedEvent

from Products.ploneundelete.interfaces import ICanBeUndeleted
from Products.ploneundelete.interfaces import IUndeleteContainer
from Products.ploneundelete.interfaces import IUndeleteSupport
from Products.ploneundelete import UndeleteSupport
from Products.ploneundelete import prepareForUndelete

def setUp(test):
    placelesssetup.setUp()
    ztapi.provideAdapter(IAttributeAnnotatable, IAnnotations,
                         AttributeAnnotations)
    ztapi.provideAdapter(IUndeleteContainer, IUndeleteSupport,
                         UndeleteSupport)
    ztapi.subscribe((ICanBeUndeleted, IObjectWillBeRemovedEvent),
                    provided=None, factory=prepareForUndelete)

def test_suite():
    return unittest.TestSuite((
        DocFileSuite('README.txt',
                     package='Products.ploneundelete',
                     setUp=setUp,
                     tearDown=placelesssetup.tearDown),
        ))

if __name__ == '__main__':
    unittest.main(defaultTest='test_suite')