当前位置: 首页>>代码示例>>Python>>正文


Python dummy.DummyContent类代码示例

本文整理汇总了Python中Products.CMFCore.tests.base.dummy.DummyContent的典型用法代码示例。如果您正苦于以下问题:Python DummyContent类的具体用法?Python DummyContent怎么用?Python DummyContent使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了DummyContent类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_search_restrict_manager

    def test_search_restrict_manager(self):
        catalog = self._makeOne()
        now = DateTime()
        dummy = DummyContent(catalog=1)

        self.loginManager()

        # already expired
        dummy.effective = now-4
        dummy.expires = now-2
        catalog.catalog_object(dummy, '/dummy')
        self.assertEqual(1, len(catalog._catalog.searchResults()))
        self.assertEqual(1, len(catalog.searchResults()))

        self.assertEqual(1, len(catalog.searchResults(
            expires={'query': now-3, 'range': 'min'})))
        self.assertEqual(0, len(catalog.searchResults(
            expires={'query': now-1, 'range': 'min'})))
        self.assertEqual(0, len(catalog.searchResults(
            expires={'query': now-3, 'range': 'max'})))
        self.assertEqual(1, len(catalog.searchResults(
            expires={'query': now-1, 'range': 'max'})))
        self.assertEqual(1, len(catalog.searchResults(
            expires={'query': (now-3, now-1), 'range': 'min:max'})))
        self.assertEqual(1, len(catalog.searchResults(
            expires={'query': (now-3, now-1), 'range': 'minmax'})))
        self.assertEqual(1, len(catalog.searchResults(
            expires={'query': now-2})))
        self.assertEqual(1, len(catalog.searchResults(
            expires={'query': now-2, 'range': None})))
开发者ID:goschtl,项目名称:zope,代码行数:30,代码来源:test_CatalogTool.py

示例2: test_doActionFor_mixture

    def test_doActionFor_mixture(self):

        wftool = self.site.portal_workflow
        wf = self._getDummyWorkflow()
        
        # This time, disallow Authenticated and Manager
        wf.states['confidential'].permission_roles = {'View': ('Authenticated', 'Manager'),}
       
        dummy = DummyContent() 
        
        # Now, if the item is normally granted to these roles
        dummy.manage_permission('View', ['Authenticated', 'Manager', 'Owner',], acquire=1)

        dummy = self.site._setObject('dummy', dummy)
        
        # These are the roles we know about
        self.assertEqual(['Anonymous', 'Authenticated', 'Manager', 'Owner'], sorted(dummy.validRoles()))
        
        self.assertEqual(wf._getStatusOf(dummy),
                         {'state': 'nonconfidential', 'comments': ''})
        
        # Then in the non-confidential state (no permissions ticked) we still have that role
        self.assertEquals(['Authenticated', 'Manager', 'Owner'], sorted(rolesForPermissionOn('View', dummy)))
                          
        wf.doActionFor(dummy, 'make_confidential', comment='foo' )
        self.assertEqual(wf._getStatusOf(dummy),
                         {'state': 'confidential', 'comments': 'foo'})
        
        # But after moving to confidential, which disallows Anonymous and Authenticated,
        # we are left with Owner and Manager
        self.assertEquals(['Owner'], sorted(rolesForPermissionOn('View', dummy)))
开发者ID:collective,项目名称:collective.subtractiveworkflow,代码行数:31,代码来源:test_permissions.py

示例3: test_search_restrict_inactive

    def test_search_restrict_inactive(self):
        catalog = self._makeOne()
        now = DateTime()
        dummy = DummyContent(catalog=1)
        dummy._View_Permission = ('Blob',)

        self.loginWithRoles('Blob')

        # already expired
        dummy.effective = now-4
        dummy.expires = now-2
        catalog.catalog_object(dummy, '/dummy')
        self.assertEqual(1, len(catalog._catalog.searchResults()))
        self.assertEqual(0, len(catalog.searchResults()))

        self.assertEqual(0, len(catalog.searchResults(
            expires={'query': now-3, 'range': 'min'})))
        self.assertEqual(0, len(catalog.searchResults(
            expires={'query': now-3, 'range': 'max'})))
        self.assertEqual(0, len(catalog.searchResults(
            expires={'query': now+3, 'range': 'min'})))
        self.assertEqual(0, len(catalog.searchResults(
            expires={'query': now+3, 'range': 'max'})))
        self.assertEqual(0, len(catalog.searchResults(
            expires={'query': (now-3, now-1), 'range': 'min:max'})))
        self.assertEqual(0, len(catalog.searchResults(
            expires={'query': (now-3, now-1), 'range': 'minmax'})))
        self.assertEqual(0, len(catalog.searchResults(
            expires={'query': now-2, 'range': None})))
开发者ID:goschtl,项目名称:zope,代码行数:29,代码来源:test_CatalogTool.py

示例4: test_manageDelObjects

    def test_manageDelObjects(self):
        test = self._makeOne('test')
        foo = DummyContent('foo')

        test._setObject('foo', foo)
        foo.reset()
        test.manage_delObjects( ids=['foo'] )
        self.failIf( foo.after_add_called )
        self.failUnless( foo.before_delete_called )
开发者ID:goschtl,项目名称:zope,代码行数:9,代码来源:test_PortalFolder.py

示例5: test_manageDelObjects

    def test_manageDelObjects( self ):

        test = self.root.test
        foo = DummyContent( 'foo' )

        test._setObject( 'foo', foo )
        foo.reset()
        test.manage_delObjects( ids=[ 'foo' ] )
        assert not foo.after_add_called
        assert foo.before_delete_called
开发者ID:goschtl,项目名称:zope,代码行数:10,代码来源:test_PortalFolder.py

示例6: test_manageDelObjects

    def test_manageDelObjects(self):
        acl_users = self.site._setObject('acl_users', DummyUserFolder())
        newSecurityManager(None, acl_users.all_powerful_Oz)
        test = self._makeOne('test')
        foo = DummyContent('foo')

        test._setObject('foo', foo)
        foo.reset()
        test.manage_delObjects(ids=['foo'])
        self.assertFalse(foo.after_add_called)
        self.assertTrue(foo.before_delete_called)
开发者ID:goschtl,项目名称:zope,代码行数:11,代码来源:test_PortalFolder.py

示例7: __init__

 def __init__(self, id="dummy", opaqueItem=None, *args, **kw):
     OriginalDummyContent.__init__(self, id, *args, **kw)
     if opaqueItem is None:
         self.opaqueItem = "noncallable"
         self.opaqueItemsId = "opaqueItem"
     elif isinstance(opaqueItem, basestring):
         Hooks(self, opaqueItem)
         self.opaqueItemsId = opaqueItem
     else:
         opaqueItem(self, "opaqueItem")
         self.opaqueItemsId = "opaqueItem"
开发者ID:dtgit,项目名称:dtedu,代码行数:11,代码来源:test_OpaqueItems.py

示例8: test_search_member_wo_valid_roles

    def test_search_member_wo_valid_roles(self):
        catalog = self._makeOne()
        catalog.addIndex('allowedRolesAndUsers', 'KeywordIndex')
        dummy = DummyContent(catalog=1)
        dummy._View_Permission = ('Blob',)
        catalog.catalog_object(dummy, '/dummy')

        self.loginWithRoles('Waggle')

        self.assertEqual(1, len(catalog._catalog.searchResults()))
        self.assertEqual(0, len(catalog.searchResults()))
开发者ID:goschtl,项目名称:zope,代码行数:11,代码来源:test_CatalogTool.py

示例9: test_mergedLocalRolesManipulation

    def test_mergedLocalRolesManipulation(self):
        # The _mergedLocalRoles function used to return references to
        # actual local role settings and it was possible to manipulate them
        # by changing the return value. http://www.zope.org/Collectors/CMF/376
        from Products.CMFCore.tests.base.dummy import DummyContent
        from Products.CMFCore.utils import _mergedLocalRoles
        obj = DummyContent()
        obj.manage_addLocalRoles('dummyuser1', ['Manager', 'Owner'])
        self.assertEqual(len(obj.get_local_roles_for_userid('dummyuser1')), 2)

        merged_roles = _mergedLocalRoles(obj)
        merged_roles['dummyuser1'].append('FOO')

        # The values on the object itself should still the the same
        self.assertEqual(len(obj.get_local_roles_for_userid('dummyuser1')), 2)
开发者ID:goschtl,项目名称:zope,代码行数:15,代码来源:test_utils.py

示例10: test_304_response_from_cpm

    def test_304_response_from_cpm(self):
        # test that we get a 304 response from the cpm via this template
        mod_time = DateTime()
        cpm = DummyCachingManagerWithPolicy()
        getSiteManager().registerUtility(cpm, ICachingPolicyManager)
        content = DummyContent(id='content')
        content.modified_date = mod_time
        content = content.__of__(self.app)
        script = self._makeOne('testDTML', 'testDTML.dtml')
        script = script.__of__(content)
        self.REQUEST.environ['IF_MODIFIED_SINCE'
                            ] = '%s;' % rfc1123_date(mod_time + 3600)
        data = script(content, self.REQUEST, self.RESPONSE)

        self.assertEqual(data, '')
        self.assertEqual(self.RESPONSE.getStatus(), 304)
开发者ID:goschtl,项目名称:zope,代码行数:16,代码来源:test_FSDTMLMethod.py

示例11: test_304_response_from_cpm

    def test_304_response_from_cpm(self):
        # test that we get a 304 response from the cpm via this template

        from webdav.common import rfc1123_date

        mod_time = DateTime()
        self.root.caching_policy_manager = DummyCachingManagerWithPolicy()
        content = DummyContent(id="content")
        content.modified_date = mod_time
        content = content.__of__(self.root)
        script = self._makeOne("testDTML", "testDTML.dtml")
        script = script.__of__(content)
        self.REQUEST.environ["IF_MODIFIED_SINCE"] = "%s;" % rfc1123_date(mod_time + 3600)
        data = script(content, self.REQUEST, self.RESPONSE)

        self.assertEqual(data, "")
        self.assertEqual(self.RESPONSE.getStatus(), 304)
开发者ID:wpjunior,项目名称:proled,代码行数:17,代码来源:test_FSDTMLMethod.py

示例12: test_doActionFor_anonymous

    def test_doActionFor_anonymous(self):

        wftool = self.site.portal_workflow
        wf = self._getDummyWorkflow()

        dummy = DummyContent()
        
        # Now, if the item is normally granted to anonymous...
        dummy.manage_permission('View', ['Anonymous'], acquire=1)

        dummy = self.site._setObject('dummy', dummy)
        
        # These are the roles we know about
        self.assertEquals(['Anonymous', 'Authenticated', 'Manager', 'Owner'], sorted(dummy.validRoles()))
        
        self.assertEqual( wf._getStatusOf(dummy),
                          {'state': 'confidential', 'comments': ''} )
        
        self.assertEquals(['Manager', 'Owner'], sorted(rolesForPermissionOn('View', dummy)))
开发者ID:collective,项目名称:collective.subtractiveworkflow,代码行数:19,代码来源:test_permissions.py

示例13: test_deletePropagation

    def test_deletePropagation(self):
        test = self._makeOne('test')
        foo = DummyContent('foo')
        foo.reset()
        self.failIf( foo.after_add_called )
        self.failIf( foo.before_delete_called )

        test._setObject('foo', foo)
        self.failUnless( foo.after_add_called )
        self.failIf( foo.before_delete_called )

        foo.reset()
        test._delObject('foo')
        self.failIf( foo.after_add_called )
        self.failUnless( foo.before_delete_called )

        foo.reset()
        test._setObject('foo', foo)
        test._delOb('foo')    # doesn't propagate
        self.failUnless( foo.after_add_called )
        self.failIf( foo.before_delete_called )
开发者ID:goschtl,项目名称:zope,代码行数:21,代码来源:test_PortalFolder.py

示例14: test_deletePropagation

    def test_deletePropagation( self ):

        test = self.root.test
        foo = DummyContent( 'foo' )

        foo.reset()
        assert not foo.after_add_called
        assert not foo.before_delete_called
        test._setObject( 'foo', foo )
        assert foo.after_add_called
        assert not foo.before_delete_called

        foo.reset()
        test._delObject( 'foo' )
        assert not foo.after_add_called
        assert foo.before_delete_called

        foo.reset()
        test._setObject( 'foo', foo )
        test._delOb( 'foo' )    # doesn't propagate
        assert foo.after_add_called
        assert not foo.before_delete_called
开发者ID:goschtl,项目名称:zope,代码行数:22,代码来源:test_PortalFolder.py

示例15: test_deletePropagation

    def test_deletePropagation(self):
        acl_users = self.site._setObject('acl_users', DummyUserFolder())
        newSecurityManager(None, acl_users.all_powerful_Oz)
        test = self._makeOne('test')
        foo = DummyContent('foo')
        foo.reset()
        self.assertFalse(foo.after_add_called)
        self.assertFalse(foo.before_delete_called)

        test._setObject('foo', foo)
        self.assertTrue(foo.after_add_called)
        self.assertFalse(foo.before_delete_called)

        foo.reset()
        test._delObject('foo')
        self.assertFalse(foo.after_add_called)
        self.assertTrue(foo.before_delete_called)

        foo.reset()
        test._setObject('foo', foo)
        test._delOb('foo')    # doesn't propagate
        self.assertTrue(foo.after_add_called)
        self.assertFalse(foo.before_delete_called)
开发者ID:goschtl,项目名称:zope,代码行数:23,代码来源:test_PortalFolder.py


注:本文中的Products.CMFCore.tests.base.dummy.DummyContent类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。