Ejemplo n.º 1
0
    def setUp(self):
        cleanUp()

        batch = [testing.DummyModel(title="foo"), testing.DummyModel(title="bar")]

        class DummyGetImagesBatch(object):
            def __call__(self, context, request, **search_params):
                self.called = (context, request, search_params)
                return dict(
                    entries=batch,
                    batch_start=search_params["batch_start"],
                    batch_size=search_params["batch_size"],
                    total=5,
                )

        self.dummy_get_images_batch = DummyGetImagesBatch()

        def dummy_get_images_info(image, request):
            return image.title

        self.dummy_get_images_info = dummy_get_images_info

        from karl.views.imagedrawer import batch_images

        def wrapped_batch_images(*arg, **kw):
            kw["get_image_info"] = self.dummy_get_images_info
            kw["get_images_batch"] = self.dummy_get_images_batch
            return batch_images(*arg, **kw)

        self.dummy_batch_images = wrapped_batch_images
Ejemplo n.º 2
0
    def test_deleteMembers(self):
        site = self._makeSite()
        sm = getSiteManager()
        mtool = site.portal_membership
        members = site._setObject( 'Members', PortalFolder('Members') )
        acl_users = site._setObject( 'acl_users', DummyUserFolder() )
        utool = site._setObject( 'portal_url', DummyTool() )
        sm.registerUtility(utool, IURLTool)
        wtool = site._setObject( 'portal_workflow', DummyTool() )
        mdtool = site._setObject( 'portal_memberdata', MemberDataTool() )
        sm.registerUtility(mdtool, IMemberDataTool)
        newSecurityManager(None, acl_users.all_powerful_Oz)

        self.assertEqual( acl_users.getUserById('user_foo'),
                          acl_users.user_foo )
        mtool.createMemberArea('user_foo')
        self.failUnless( hasattr(members.aq_self, 'user_foo') )
        mdtool.registerMemberData('Dummy', 'user_foo')
        self.failUnless( mdtool._members.has_key('user_foo') )

        rval = mtool.deleteMembers( ('user_foo', 'user_baz') )
        self.assertEqual( rval, ('user_foo',) )
        self.failIf( acl_users.getUserById('user_foo', None) )
        self.failIf( mdtool._members.has_key('user_foo') )
        self.failIf( hasattr(members.aq_self, 'user_foo') )

        cleanUp()
Ejemplo n.º 3
0
    def setUp(self):
        cleanUp()

        self.root = root = karltesting.DummyModel()
        root['profiles'] = profiles = karltesting.DummyModel()
        root.users = karltesting.DummyUsers()

        root['a'] = a = karltesting.DummyModel(creator='chris')
        root['b'] = b = karltesting.DummyModel(modified_by='chris')

        class DummySearchAdapter(object):
            def __init__(self, context):
                pass

            def __call__(self, **kw):
                resolver = lambda x: root.get(x)
                if kw.get('creator') == 'chris':
                    return 1, ['a'], resolver
                if kw.get('modified_by') == 'chris':
                    return 1, ['b'], resolver
                return 0, [], resolver

        from zope.interface import Interface
        from karl.models.interfaces import ICatalogSearch
        testing.registerAdapter(DummySearchAdapter, (Interface, Interface),
                                ICatalogSearch)
        testing.registerAdapter(DummySearchAdapter, (Interface,),
                                ICatalogSearch)

        root.catalog = catalog = karltesting.DummyModel()
        catalog['creator'] =  DummyCatalogIndex()
        catalog['modified_by'] =  DummyCatalogIndex()
Ejemplo n.º 4
0
 def wrapper(*args, **kw):
     safe_load_site()
     value = function(*args, **kw)
     cleanUp()
     import Products.Five.zcml as zcml
     zcml._initialized = 0
     return value
Ejemplo n.º 5
0
 def setUp(self):
     cleanUp()
     sessions = DummySessions()
     context = self.context = testing.DummyModel(sessions=sessions)
     request = self.request = testing.DummyRequest()
     request.environ['repoze.browserid'] = '1'
     request.subpath = ('sub', 'path', 'parts')
Ejemplo n.º 6
0
    def tearDown(self):
        from zope.testing.cleanup import cleanUp
        cleanUp()

        from karl.adapters import mailin
        mailin.datetime = self._save_datetime
        mailin.ALIAS_REGX = None
Ejemplo n.º 7
0
    def setUp(self):
        cleanUp()

        from datetime import datetime
        site = DummyModel()
        self.site = site
        profiles = site['profiles'] = DummyModel()

        site['bigendians'] = c = DummyModel()
        c.title = 'Big Endians'
        c.modified = datetime(2009, 12, 23, 12, 31)
        c.creator = 'chucknorris'

        site['littleendians'] = c = DummyModel()
        c.title = 'Little Endians'
        c.modified = datetime(2009, 12, 26, 3, 31)
        c.creator = 'geekbill'

        p = profiles['chucknorris'] = karltesting.DummyProfile()
        p.title = 'Chuck Norris'
        p = profiles['geekbill'] = karltesting.DummyProfile()
        p.title = 'Bill Haverchuck'

        from karl.models.interfaces import ICatalogSearch
        from zope.interface import Interface
        search = DummyCatalogSearch()
        def dummy_search_factory(context):
            return search
        karltesting.registerAdapter(dummy_search_factory, Interface,
                                    ICatalogSearch)
        self.search = search

        from karl.views.admin import delete_content_view
        self.fut = delete_content_view
Ejemplo n.º 8
0
 def setUp(self):
     cleanUp()
     from AccessControl.SecurityManagement import noSecurityManager
     from AccessControl.SecurityManager import setSecurityPolicy
     from Products.CompositePage.tests.test_tool import PermissiveSecurityPolicy
     self.old_policy = setSecurityPolicy(PermissiveSecurityPolicy())
     noSecurityManager()
Ejemplo n.º 9
0
    def test_deleteMembersUnsupported(self):
        # Quite a few user folders do not support the deletion API
        # http://www.zope.org/Collectors/CMF/481
        # Make sure we get the right exception
        site = self._makeSite()
        sm = getSiteManager()
        sm.registerUtility(site, ISiteRoot)
        mtool = site.portal_membership
        members = site._setObject('Members', PortalFolder('Members'))
        acl_users = site._setObject('acl_users', DummyUserFolder())
        mdtool = MemberDataTool()
        sm.registerUtility(mdtool, IMemberDataTool)
        newSecurityManager(None, acl_users.all_powerful_Oz)

        self.assertEqual(acl_users.getUserById('user_foo'), acl_users.user_foo)
        mtool.createMemberArea('user_foo')
        self.assertTrue(hasattr(members.aq_self, 'user_foo'))
        mdtool.registerMemberData('Dummy', 'user_foo')
        self.assertTrue('user_foo' in mdtool._members)

        # Fake an incompatible user folder by deleting the class method
        deletion_method = DummyUserFolder.userFolderDelUsers
        del DummyUserFolder.userFolderDelUsers
        self.assertRaises(NotImplementedError, mtool.deleteMembers,
                          ('user_foo',))
        self.assertTrue(acl_users.getUserById('user_foo', None))
        self.assertTrue('user_foo' in mdtool._members)
        self.assertTrue(hasattr(members.aq_self, 'user_foo'))

        # Cleanup
        DummyUserFolder.userFolderDelUsers = deletion_method
        cleanUp()
Ejemplo n.º 10
0
def safe_load_site():
    """Load entire component architecture (w/ debug mode on)"""
    cleanUp()
    setDebugMode(1)
    import Products.Five.zcml as zcml
    zcml.load_site()
    setDebugMode(0)
Ejemplo n.º 11
0
 def tearDown(self):
     self.app.REQUEST.close()
     noSecurityManager()
     transaction.abort()
     self.app._p_jar.close()
     Skinnable.SKINDATA = self._oldSkindata
     cleanUp()
Ejemplo n.º 12
0
def tearDown(self):
    """Test tearDown based on z3c.form.testing.tearDown minus their globals.
    """
    from zope.testing import cleanup
    from zope.component import hooks
    cleanup.cleanUp()
    hooks.resetHooks()
    hooks.setSite()
Ejemplo n.º 13
0
def tearDownReadMe(test):
    # clean up Zope
    cleanup.cleanUp()

    # clean up SQLAlchemy
    Base = test.globs['Base']
    engine = test.globs['engine']
    Base.metadata.drop_all(engine)
Ejemplo n.º 14
0
    def tearDown(self):
        from AccessControl.SecurityManagement import noSecurityManager

        if self._finally is not None:
            self._finally()

        noSecurityManager()
        cleanUp()
Ejemplo n.º 15
0
 def setUp(self):
     cleanUp()
     sessions = DummySessions()
     context = DummyProfile(sessions=sessions)
     context.title = 'title'
     self.context = context
     request = testing.DummyRequest()
     request.environ['repoze.browserid'] = '1'
     self.request = request
Ejemplo n.º 16
0
 def setUp(self):
     """ This sets up the application registry with the
     registrations your application declares in its configure.zcml
     (including dependent registrations for repoze.bfg itself).
     """
     cleanUp()
     import myproject
     import zope.configuration.xmlconfig
     zope.configuration.xmlconfig.file('configure.zcml', package=myproject)
Ejemplo n.º 17
0
    def setUp(self):
        cleanUp()

        from karl.content.models import blog
        self._save_os = blog.os
        blog.os = self
        self._utime_called = None
        self._exists = set()

        testing.registerSettings(mailin_trace_file='trace_file')
Ejemplo n.º 18
0
 def tearDown(self):
     from AccessControl.SecurityManagement import noSecurityManager
     noSecurityManager()
     ZopeTestCase.tearDown(self)
     try:
         from zope.testing.cleanup import cleanUp
         cleanUp()
     except ImportError:
         # BBB: for Zope 2.8
         pass
Ejemplo n.º 19
0
 def setUp(self):
     cleanUp()
     sessions = self.sessions = DummySessions()
     context = testing.DummyModel(sessions=sessions)
     context.title = 'profiles'
     self.context = context
     request = testing.DummyRequest()
     request.environ['repoze.browserid'] = '1'
     self.request = request
     karltesting.registerSettings()
Ejemplo n.º 20
0
    def setUp(self):
        cleanUp()

        self.root = root = testing.DummyModel()
        root.users = testing.DummyUsers()
        root['profiles'] = testing.DummyModel()

        from repoze.lemonade.testing import registerContentFactory
        from karl.models.interfaces import IProfile
        registerContentFactory(testing.DummyProfile, IProfile)
Ejemplo n.º 21
0
    def setUp(self):
        cleanUp()

        self.parent = DummyModel(title='dummyparent')
        self.context = DummyModel(title='dummytitle', text='dummytext')
        self.context['attachments'] = DummyModel()
        self.parent['child'] = self.context
        self.parent.catalog = DummyCatalog()
        self.parent["profiles"] = DummyModel()
        users = self.parent.users = DummyUsers()
        users.add("userid", "userid", "password", [])
Ejemplo n.º 22
0
    def setUp(self):
        cleanUp()

        from repoze.lemonade.testing import registerContentFactory
        from karl.content.interfaces import ICommunityFile
        registerContentFactory(testing.DummyModel, ICommunityFile)

        from zope.interface import Interface
        from repoze.workflow.testing import registerDummyWorkflow
        self.workflow = DummyWorkflow()
        registerDummyWorkflow('security', self.workflow, Interface)
Ejemplo n.º 23
0
 def setUp(self):
     cleanUp()
     self.sessions = sessions = DummySessions()
     context = DummyProfile(sessions=sessions)
     context.title = 'title'
     self.context = context
     request = testing.DummyRequest()
     request.environ['repoze.browserid'] = '1'
     self.request = request
     # this initializes the available groups
     karltesting.registerSettings()
Ejemplo n.º 24
0
    def setUp(tc):
        # clean slate!
        cleanUp()

        # init event system
        from zope.component import event

        # register components
        provideHandler(notifyFieldEvent)
        provideAdapter(at_field_retrieval)
        provideSubscriptionAdapter(at_field_storage)
Ejemplo n.º 25
0
    def setUp(self):
        cleanUp()

        from karl.models.interfaces import ICommunity
        from zope.interface import directlyProvides

        from datetime import datetime
        site = DummyModel()
        self.site = site
        profiles = site['profiles'] = DummyModel()

        site['bigendians'] = c = DummyModel()
        directlyProvides(c, ICommunity)
        c.title = 'Big Endians'
        c.modified = datetime(2009, 12, 23, 12, 31)
        c.creator = 'chucknorris'

        blog = c['blog'] = DummyModel()
        entry = blog['entry1'] = DummyModel()
        entry.title = 'Blog Post 1'
        entry.modified = datetime(2009, 12, 23, 12, 31)
        entry.creator = 'chucknorris'

        entry = blog['entry2'] = DummyModel()
        entry.title = 'Blog Post 2'
        entry.modified = datetime(2009, 12, 23, 13, 31)
        entry.creator = 'chucknorris'

        site['littleendians'] = c = DummyModel()
        directlyProvides(c, ICommunity)
        c.title = 'Little Endians'
        c.modified = datetime(2009, 12, 26, 3, 31)
        c.creator = 'geekbill'
        c['blog'] = DummyModel()

        p = profiles['chucknorris'] = karltesting.DummyProfile()
        p.title = 'Chuck Norris'
        p = profiles['geekbill'] = karltesting.DummyProfile()
        p.title = 'Bill Haverchuck'

        from karl.models.interfaces import ICatalogSearch
        from zope.interface import Interface
        search = DummyCatalogSearch()
        def dummy_search_factory(context):
            return search
        karltesting.registerAdapter(dummy_search_factory, Interface,
                                    ICatalogSearch)
        self.search = search

        from karl.views.admin import move_content_view
        self.fut = move_content_view
Ejemplo n.º 26
0
    def setUp(self):
        cleanUp()

        import tempfile
        self.tmpdir = tmpdir = tempfile.mkdtemp('karl_test')

        self.site = testing.DummyModel()

        from repoze.bfg.interfaces import ISettings
        settings = karltesting.DummySettings(
            error_monitor_dir=tmpdir,
            error_monitor_subsystems=["blonde", "red", "head"],
        )
        testing.registerUtility(settings, ISettings)
Ejemplo n.º 27
0
    def setUp(self):
        cleanUp()

        import os
        import sys
        here = os.path.abspath(os.path.dirname(sys.modules[__name__].__file__))
        from repoze.bfg.interfaces import ISettings
        self.settings = settings = karltesting.DummySettings(
            syslog_view=os.path.join(here, 'test.log'),
            syslog_view_instances=['org1', 'org2'],
        )
        testing.registerUtility(settings, ISettings)

        from karl.views.admin import syslog_view
        self.fut = syslog_view
Ejemplo n.º 28
0
    def setUp(self):
        from zope.testing.cleanup import cleanUp
        cleanUp()

        import datetime
        from karl.adapters import mailin
        self._save_datetime = mailin.datetime

        class DummyDateTime(object):
            def __init__(self):
                self.datetime = self
            def now(self):
                return datetime.datetime(1975, 7, 7, 7, 30)
            def __call__(self, *args):
                return datetime.datetime(*args)

        mailin.datetime = DummyDateTime()
Ejemplo n.º 29
0
    def setUp(self):
        cleanUp()

        import os
        import sys
        here = os.path.abspath(os.path.dirname(sys.modules[__name__].__file__))
        from repoze.bfg.interfaces import ISettings

        self.logs = [os.path.join(here, 'test.log'),
                     os.path.join(here, 'test_admin.py')]
        settings = karltesting.DummySettings(
            logs_view=self.logs
        )
        testing.registerUtility(settings, ISettings)

        from karl.views.admin import logs_view
        self.fut = logs_view
Ejemplo n.º 30
0
    def setUp(self):
        cleanUp()

        batch = [testing.DummyModel(title="A"), testing.DummyModel(title="B")]

        class DummyBatcher(object):
            def __call__(
                self, context, request, creator, community, batch_start, batch_size, sort_index=None, reverse=False
            ):
                self.called = (context, request, creator, community, batch_start, batch_size, sort_index, reverse)
                return dict(entries=batch, batch_start=batch_start, batch_size=batch_size, total=5)

        self.batcher = DummyBatcher()

        def dummy_get_info(image, request):
            return dict(title=image.title)

        self.make_record = dummy_get_info
Ejemplo n.º 31
0
 def tearDown(self):
     from AccessControl.SecurityManagement import noSecurityManager
     from zope.testing.cleanup import cleanUp
     cleanUp()
     noSecurityManager()
Ejemplo n.º 32
0
 def tearDown(self):
     from zope.testing.cleanup import cleanUp
     cleanUp()
     SecurityTest.tearDown(self)
Ejemplo n.º 33
0
 def setUp(self):
     cleanUp()
Ejemplo n.º 34
0
def cleanUpDoc(args):
    cleanUp()
Ejemplo n.º 35
0
def cleanUp(test):
    from zope.testing import cleanup
    cleanup.cleanUp()
Ejemplo n.º 36
0
def cleanUp(test):
    cleanup.cleanUp()
 def tearDown(self):
     cleanUp()
     RequestTest.tearDown(self)
Ejemplo n.º 38
0
 def tearDown(self):
     cleanUp()
     FSDVTest.tearDown(self)
     TransactionalTest.tearDown(self)
Ejemplo n.º 39
0
 def tearDown(self):
     TestCase.tearDown(self)
     cleanUp()
Ejemplo n.º 40
0
 def tearDown(self):
     BaseRegistryTests.tearDown(self)
     cleanUp()
Ejemplo n.º 41
0
 def setUp(self):
     cleanUp()
     self.context = testing.DummyModel()
     from karl.testing import registerCatalogSearch
     registerCatalogSearch()
Ejemplo n.º 42
0
 def tearDown(self):
     cleanUp()
     SecurityRequestTest.tearDown(self)
Ejemplo n.º 43
0
 def setUp(cls):
     cleanup.cleanUp()
     zcml.load_site(force=True)
     component.provideHandler(eventlog.trace, (ITestItem, IObjectEvent))
     component.provideHandler(eventlog.trace, (ITestFolder, IObjectEvent))
Ejemplo n.º 44
0
def tearDown(test):
    from zope.testing import cleanup
    from zope.component import hooks
    cleanup.cleanUp()
    hooks.resetHooks()
    hooks.setSite()
Ejemplo n.º 45
0
def cleanUpZope(test):
    cleanup.cleanUp()
Ejemplo n.º 46
0
    def setUp(self):
        from zope.testing.cleanup import cleanUp

        cleanUp()
        self._registerAdapters()
Ejemplo n.º 47
0
 def tearDown(self):
     cleanUp()
Ejemplo n.º 48
0
 def testTearDown(cls):
     cleanUp()
Ejemplo n.º 49
0
 def tearDown(self):
     RequestTest.tearDown(self)
     FSDVTest.tearDown(self)
     cleanUp()
Ejemplo n.º 50
0
def tearDown(test):
    cleanup.cleanUp()
Ejemplo n.º 51
0
 def setUp(self):
     cleanUp()
     site = self.site = testing.DummyModel()
     context = self.context = testing.DummyModel()
     site['context'] = context
 def tearDown(self):
     cleanUp()
     SecurityTest.tearDown(self)
     FSPSMaker.tearDown(self)
Ejemplo n.º 53
0
 def tearDown(self):
     cleanUp()
     FSSTXMaker.tearDown(self)
     _TemplateSwitcher.tearDown(self)
     SecurityTest.tearDown(self)
Ejemplo n.º 54
0
 def tearDown(cls):
     cleanUp()
Ejemplo n.º 55
0
 def setUp(self):
     cleanUp()
     karltesting.registerLayoutProvider()
Ejemplo n.º 56
0
 def setUp(cls):
     cleanup.cleanUp()
     zcml.load_site(force=True)
     setDeprecatedManageAddDelete(TestItem)
     setDeprecatedManageAddDelete(TestFolder)
Ejemplo n.º 57
0
 def afterClear(self):
     cleanup.cleanUp()
     sys.path[:] = self.saved
Ejemplo n.º 58
0
    def afterSetUp(self):
        cleanup.cleanUp()
        zcml.load_site(force=True)

        self.saved = sys.path[:]
        sys.path.append(ZopeTestCase.__path__[0])
Ejemplo n.º 59
0
 def tearDown(self):
     cleanUp()
     SecurityTest.tearDown(self)
Ejemplo n.º 60
0
 def tearDown(self):
     from Products.CMFCore.Skinnable import SKINDATA
     SKINDATA.clear()
     cleanUp()