Пример #1
0
    def setUp(test):
        functional.FunctionalTestSetup().setUp()

        newInteraction()

        def fake_utcnow(self):
            return datetime.datetime(2015, 7, 30, 8, 0, 0)

        curse(datetime.datetime, 'utcnow', classmethod(fake_utcnow))

        root = functional.getRootFolder()
        setSite(root)
        sm = root.getSiteManager()

        # IIntIds
        root['intids'] = IntIds()
        sm.registerUtility(root['intids'], IIntIds)
        root['intids'].register(root)

        # catalog
        root['catalog'] = Catalog()
        sm.registerUtility(root['catalog'], ICatalog)

        # PluggableAuthentication
        pau = PluggableAuthentication(u'')
        event.notify(ObjectCreatedEvent(pau))
        sm[u'auth'] = pau
        sm.registerUtility(pau, IAuthentication)

        # Credentials Plugin
        defaultCreds.install()
        defaultCreds.activate()

        # people
        people = PersonalSpaceManager(title=u'People')
        event.notify(ObjectCreatedEvent(people))
        root['people'] = people
        sm.registerUtility(root['people'], IPersonalSpaceManager)

        user = sm.getUtility(IAuthentication).getPrincipal('zope.mgr')
        people.assignPersonalSpace(user)

        user = sm.getUtility(IAuthentication).getPrincipal('zope.user')
        people.assignPersonalSpace(user)

        # default content
        content = Content(u'Content1', u'Some Content1')
        event.notify(ObjectCreatedEvent(content))
        IOwnership(content).ownerId = 'zope.user'
        root['content1'] = content

        content = Content(u'Content2', u'Some Content2')
        event.notify(ObjectCreatedEvent(content))
        IOwnership(content).ownerId = 'zope.user'
        root['content2'] = content

        endInteraction()