• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python testing.registerDummySecurityPolicy函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: test_user_home_path_w_subpath

    def test_user_home_path_w_subpath(self):
        from zope.interface import Interface
        from zope.interface import directlyProvides
        from repoze.bfg.interfaces import ITraverserFactory
        from karl.testing import DummyCommunity
        from karl.testing import DummyProfile
        testing.registerDummySecurityPolicy("userid")
        c = DummyCommunity()
        site = c.__parent__.__parent__
        directlyProvides(site, Interface)
        c["foo"] = foo = testing.DummyModel()
        site["profiles"] = profiles = testing.DummyModel()
        profiles["userid"] = profile = DummyProfile()
        profile.home_path = "/communities/community/foo/bar/baz"
        testing.registerAdapter(
            dummy_traverser_factory, Interface, ITraverserFactory
        )

        from karl.views.utils import get_user_home
        request = testing.DummyRequest()

        # Test from site root
        target, extra_path = get_user_home(site, request)
        self.failUnless(foo is target)
        self.assertEqual(['bar', 'baz'], extra_path)

        # Test from arbitrary point in tree
        target, extra_path = get_user_home(c, request)
        self.failUnless(foo is target)
        self.assertEqual(['bar', 'baz'], extra_path)
开发者ID:boothead,项目名称:karl,代码行数:30,代码来源:test_utils.py


示例2: test_non_defaults

    def test_non_defaults(self):
        from karl.content.interfaces import IImage

        testing.registerDummySecurityPolicy("chris")
        context = testing.DummyModel()
        community = context["community"] = testing.DummyModel()
        request = testing.DummyRequest()
        batcher = DummyBatcher()
        params = dict(
            community=community,
            creator="chris",
            sort_index="foo_index",
            reverse=False,
            batch_start=20,
            batch_size=10,
            batcher=batcher,
        )
        self._call_fut(context, request, **params)

        self.assertEqual(batcher.context, context)
        self.assertEqual(batcher.request, request)
        self.assertEqual(batcher["interfaces"], [IImage])
        self.assertEqual(
            batcher["allowed"], {"query": ["system.Everyone", "system.Authenticated", "chris"], "operator": "or"}
        )
        self.assertEqual(batcher["sort_index"], "foo_index")
        self.assertEqual(batcher["reverse"], False)
        self.assertEqual(batcher["batch_start"], 20)
        self.assertEqual(batcher["batch_size"], 10)
        self.assertEqual(batcher["path"], community)
        self.assertEqual(batcher["creator"], "chris")
开发者ID:boothead,项目名称:karl,代码行数:31,代码来源:test_image.py


示例3: test_communities_nonviewable_filtered

    def test_communities_nonviewable_filtered(self):
        self._registerTagbox()
        self._registerCatalogSearch()

        from repoze.bfg.testing import DummyModel
        from repoze.bfg.testing import registerDummySecurityPolicy
        registerDummySecurityPolicy(permissive=False)
        from karl.testing import DummyCommunity
        from karl.testing import DummyUsers
        renderer = testing.registerDummyRenderer('templates/profile.pt')
        request = testing.DummyRequest()
        context = DummyProfile()
        users = DummyUsers()

        community1 = DummyCommunity()
        community1.title = "Community 1"

        communities = community1.__parent__
        communities["community2"] = community2 = DummyCommunity()
        community2.title = "Community 2"
        users.add("userid", "userid", "password",
                  ["group.community:community:members",
                   "group.community:community2:moderators"])

        site = communities.__parent__
        site.users = users
        site["profiles"] = profiles = DummyModel()
        profiles["userid"] = context

        self._callFUT(context, request)
        self.assertEqual(renderer.communities, [])
开发者ID:boothead,项目名称:karl,代码行数:31,代码来源:test_people.py


示例4: test_handle_submit_valid_nofile_withremove

    def test_handle_submit_valid_nofile_withremove(self):
        from repoze.bfg.formish import ValidationError
        from karl.models.interfaces import ISite
        from zope.interface import directlyProvides
        from schemaish.type import File as SchemaFile
        from karl.models.interfaces import IObjectModifiedEvent
        from karl.content.interfaces import ICommunityFile
        from repoze.lemonade.interfaces import IContentFactory

        self._register()

        context = DummyFile(title='oldtitle')
        context.__name__ = None
        context.__parent__ = None
        context.mimetype = 'old/type'
        context.filename = 'old_name'
        context.stream = 'old'
        context.sessions = DummySessions()
        context.catalog = DummyCatalog()
        directlyProvides(context, ISite)
        converted = {
            'title': 'new title',
            'file': SchemaFile(None, None, None, metadata={'remove':True}),
            'security_state': 'public',
            'tags': ['thetesttag'],
            }
        testing.registerAdapter(lambda *arg: DummyCommunityFile,
                                (ICommunityFile,),
                                IContentFactory)
        testing.registerDummySecurityPolicy('testeditor')
        request = self._makeRequest()
        controller = self._makeOne(context, request)
        self.assertRaises(ValidationError, controller.handle_submit, converted)
开发者ID:boothead,项目名称:karl,代码行数:33,代码来源:test_files.py


示例5: test_jquery_set_preferred_view

 def test_jquery_set_preferred_view(self):
     from zope.interface import Interface
     from opencore.models.interfaces import ICommunityInfo
     context = testing.DummyModel(communities_name='communities')
     communities = context['communities'] = testing.DummyModel()
     yo = testing.DummyModel()
     yo.title = 'Yo'
     yi = testing.DummyModel()
     yi.title = 'Yi'
     communities['yo'] = yo
     communities['yi'] = yi
     profiles = context['profiles'] = testing.DummyModel()
     foo = profiles['foo'] = testing.DummyModel()
     foo.preferred_communities = None
     request = testing.DummyRequest()
     request.params = RequestParamsWithGetall()
     request.params['preferred[]'] = ['Yi']
     testing.registerDummySecurityPolicy(
         'foo',
         [
         'group.community:yo:members',
         'group.community:yo:moderators',
         'group.community:yi:moderators',
         ]
         )
     testing.registerAdapter(DummyAdapterWithTitle, (Interface, Interface),
                             ICommunityInfo)
     result = self._callFUT(context, request)
     self.assertEqual(result['my_communities'][0].context, yi)
开发者ID:lonetwin,项目名称:opencore,代码行数:29,代码来源:test_communities.py


示例6: test_get_preferred_communities_old_profile

 def test_get_preferred_communities_old_profile(self):
     from zope.interface import Interface
     from karl.models.interfaces import ICommunityInfo
     context = testing.DummyModel()
     yo = testing.DummyModel()
     yo.title = 'Yo'
     yi = testing.DummyModel()
     yi.title = 'Yi'
     context['yo'] = yo
     context['yi'] = yi
     profiles = context['profiles'] = testing.DummyModel()
     foo = profiles['foo'] = testing.DummyModel()
     request = testing.DummyRequest()
     testing.registerDummySecurityPolicy(
         'foo',
         groupids=[
         'group.community:yo:members',
         'group.community:yo:moderators',
         'group.community:yi:moderators',
         'group.community:yang:moderators'
         ]
         )
     testing.registerAdapter(DummyAdapter, (Interface, Interface),
                             ICommunityInfo)
     result = self._callFUT(context, request)
     self.assertEqual(result, None)
开发者ID:cguardia,项目名称:karl,代码行数:26,代码来源:test_communities.py


示例7: test_non_defaults

    def test_non_defaults(self):
        from karl.content.interfaces import IImage
        testing.registerDummySecurityPolicy('chris')
        context = testing.DummyModel()
        community = context['community'] = testing.DummyModel()
        request = testing.DummyRequest()
        batcher = DummyBatcher()
        params = dict(
            community=community,
            creator='chris',
            sort_index='foo_index',
            reverse=False,
            batch_start=20,
            batch_size=10,
            batcher=batcher,
        )
        self._call_fut(context, request, **params)

        self.assertEqual(batcher.context, context)
        self.assertEqual(batcher.request, request)
        self.assertEqual(batcher['interfaces'], [IImage,])
        self.assertEqual(
            batcher['allowed'],
            {'query': ['system.Everyone', 'system.Authenticated', 'chris'],
             'operator': 'or'}
        )
        self.assertEqual(batcher['sort_index'], 'foo_index')
        self.assertEqual(batcher['reverse'], False)
        self.assertEqual(batcher['batch_start'], 20)
        self.assertEqual(batcher['batch_size'], 10)
        self.assertEqual(batcher['path'], community)
        self.assertEqual(batcher['creator'], 'chris')
开发者ID:cguardia,项目名称:karl,代码行数:32,代码来源:test_image.py


示例8: test_handle_submit_titlechange

 def test_handle_submit_titlechange(self):
     from karl.testing import DummyCatalog
     self._register()
     converted = {
         'text':'text',
         'title':'newtitle',
         'sendalert': True,
         'security_state': 'public',
         'tags': 'thetesttag',
         }
     context = testing.DummyModel(title='oldtitle')
     context.text = 'oldtext'
     def change_title(newtitle):
         context.title = newtitle
     context.change_title = change_title
     context.catalog = DummyCatalog()
     request = testing.DummyRequest()
     from karl.models.interfaces import IObjectModifiedEvent
     from zope.interface import Interface
     L = testing.registerEventListener((Interface, IObjectModifiedEvent))
     testing.registerDummySecurityPolicy('testeditor')
     controller = self._makeOne(context, request)
     response = controller.handle_submit(converted)
     self.assertEqual(L[0], context)
     self.assertEqual(L[1].object, context)
     self.assertEqual(
         response.location,
         'http://example.com/?status_message=Wiki%20Page%20edited')
     self.assertEqual(context.text, 'text')
     self.assertEqual(context.modified_by, 'testeditor')
     self.assertEqual(context.title, 'newtitle')
开发者ID:boothead,项目名称:karl,代码行数:31,代码来源:test_wiki.py


示例9: test_already_member

 def test_already_member(self):
     from zope.interface import Interface
     from zope.interface import directlyProvides
     from karl.models.interfaces import ICommunity
     context = testing.DummyModel(title='thetitle')
     context.member_names = set(('userid',))
     context.moderator_names = set()
     directlyProvides(context, ICommunity)
     foo = testing.DummyModel()
     request = testing.DummyRequest()
     renderer = testing.registerDummyRenderer('templates/community.pt')
     from karl.models.interfaces import ICommunityInfo
     from karl.models.interfaces import ICatalogSearch
     from karl.models.interfaces import IGridEntryInfo
     from karl.models.adapters import CatalogSearch
     catalog = karltesting.DummyCatalog({1:'/foo'})
     testing.registerModels({'/foo':foo})
     context.catalog = catalog
     testing.registerAdapter(DummyGridEntryAdapter, (Interface, Interface),
                             IGridEntryInfo)
     testing.registerAdapter(DummyAdapter, (Interface, Interface),
                             ICommunityInfo)
     testing.registerAdapter(CatalogSearch, (Interface), ICatalogSearch)
     testing.registerDummySecurityPolicy('userid')
     self._callFUT(context, request)
     self.assertEqual(len(renderer.actions), 2)
     self.assertEqual(renderer.actions, [
         ('Edit', 'edit.html'),
         ('Delete', 'delete.html'),
     ])
开发者ID:boothead,项目名称:karl,代码行数:30,代码来源:test_community.py


示例10: test_with_security_policy

    def test_with_security_policy(self):
        self._register()
        self._registerLayoutProvider()
        import datetime
        _NOW = datetime.datetime.now()
        context = testing.DummyModel(title='title')
        from karl.content.interfaces import IForum
        alsoProvides(context, IForum)
        context['profiles'] = profiles = testing.DummyModel()
        profiles['dummy'] = DummyProfile()
        context['comments'] = testing.DummyModel()
        comment = testing.DummyModel(text='sometext')
        comment.creator = 'dummy'
        comment.created = _NOW
        context['comments']['1'] = comment
        context['attachments'] = testing.DummyModel()
        request = testing.DummyRequest()
        def dummy_byline_info(context, request):
            return context
        from karl.content.views.interfaces import IBylineInfo
        testing.registerAdapter(dummy_byline_info, (Interface, Interface),
                                IBylineInfo)
        self._register()
        testing.registerDummySecurityPolicy(permissive=False)

        renderer = testing.registerDummyRenderer(
            'templates/show_forum_topic.pt')
        self._callFUT(context, request)

        self.assertEqual(renderer.comments[0]['edit_url'], None)
开发者ID:boothead,项目名称:karl,代码行数:30,代码来源:test_forum.py


示例11: test_tags

    def test_tags(self):
        from karl.testing import DummyUsers
        self._registerTagbox()
        self._registerCatalogSearch()
        testing.registerDummySecurityPolicy('eddie')
        TAGS = {'beaver': 1, 'wally': 3}
        context = DummyProfile()
        context.title = "Eddie"
        context.__name__ = "eddie"
        users = context.users = DummyUsers()
        users.add("eddie", "eddie", "password", [])
        tags = context.tags = testing.DummyModel()
        def _getTags(items=None, users=None, community=None):
            assert items is None
            assert list(users) == ['eddie']
            assert community is None
            return TAGS.keys()
        tags.getTags = _getTags
        def _getFrequency(tags=None, community=None, user=None):
            assert community is None
            assert tags is not None
            assert user == 'eddie'
            return TAGS.items()
        tags.getFrequency = _getFrequency
        request = testing.DummyRequest()
        renderer = testing.registerDummyRenderer('templates/profile.pt')

        response = self._callFUT(context, request)

        self.assertEqual(len(renderer.tags), 2)
        self.failUnless(renderer.tags[0], {'name': 'wally', 'count': 3})
        self.failUnless(renderer.tags[1], {'name': 'beaver', 'count': 1})
开发者ID:boothead,项目名称:karl,代码行数:32,代码来源:test_people.py


示例12: test_submit_form

    def test_submit_form(self):
        from repoze.sendmail.interfaces import IMailDelivery
        testing.registerDummyRenderer("templates/join_community.pt")

        c = karltesting.DummyCommunity()
        c.moderator_names = set(["moderator1", "moderator2"])
        site = c.__parent__.__parent__
        profiles = site["profiles"] = testing.DummyModel()
        profiles["user"] = karltesting.DummyProfile()
        profiles["moderator1"] = karltesting.DummyProfile()
        profiles["moderator2"] = karltesting.DummyProfile()

        mailer = karltesting.DummyMailer()
        testing.registerUtility(mailer, IMailDelivery)

        testing.registerDummySecurityPolicy("user")
        request = testing.DummyRequest({
            "form.submitted": "1",
            "message": "Message text.",
        })
        testing.registerDummyRenderer(
            'karl.views:templates/email_join_community.pt')
        response = self._callFUT(c, request)

        self.assertEqual(response.location,
                         "http://example.com/communities/community/"
                         "?status_message=Your+request+has+been+sent+"
                         "to+the+moderators.")
        self.assertEqual(len(mailer), 1)
        msg = mailer.pop()
        self.assertEqual(msg.mto, ["[email protected]",
                                   "[email protected]"])
开发者ID:cguardia,项目名称:karl,代码行数:32,代码来源:test_community.py


示例13: test_jquery_list_my_communities_view

 def test_jquery_list_my_communities_view(self):
     from zope.interface import Interface
     from opencore.models.interfaces import ICommunityInfo
     context = testing.DummyModel(communities_name='communities')
     communities = context['communities'] = testing.DummyModel()
     yo = testing.DummyModel()
     yo.title = 'Yo'
     yi = testing.DummyModel()
     yi.title = 'Yi'
     communities['yo'] = yo
     communities['yi'] = yi
     profiles = context['profiles'] = testing.DummyModel()
     foo = profiles['foo'] = testing.DummyModel()
     foo.preferred_communities = ['Yi']
     request = testing.DummyRequest()
     testing.registerDummySecurityPolicy(
         'foo',
         groupids=[
         'group.community:yo:members',
         'group.community:yo:moderators',
         'group.community:yi:moderators',
         'group.community:yang:moderators'
         ]
         )
     testing.registerAdapter(DummyAdapterWithTitle, (Interface, Interface),
                             ICommunityInfo)
     result = self._callFUT(context, request)
     self.assertEqual(result['preferred'], ['Yi'])
     self.assertEqual(result['show_all'], True)
     self.assertEqual(len(result['my_communities']), 2)
开发者ID:lonetwin,项目名称:opencore,代码行数:30,代码来源:test_communities.py


示例14: test_handle_submit_full_path_filename

    def test_handle_submit_full_path_filename(self):
        from schemaish.type import File as SchemaFile
        from karl.content.interfaces import ICommunityFile
        from repoze.lemonade.testing import registerContentFactory
        from repoze.bfg.formish import ValidationError
        self._register()
        self._registerLayoutProvider()

        testing.registerDummySecurityPolicy('userid')
        context = self._makeContext()
        context.catalog = DummyCatalog()
        fs = SchemaFile('abc', r"C:\Documents and Settings\My Tests\filename",
                        'x/foo')
        converted = {
            'file': fs,
            'title': 'a title',
            'sendalert': False,
            'security_state': 'public',
            'tags':['thetesttag'],
            }
        request = self._makeRequest()
        registerContentFactory(DummyCommunityFile, ICommunityFile)
        controller = self._makeOne(context, request)
        response = controller.handle_submit(converted)
        self.assertEqual(response.location, 'http://example.com/filename/')
        self.assertEqual(context['filename'].title, u'a title')
        self.assertEqual(context['filename'].creator, 'userid')
        self.assertEqual(context['filename'].stream, 'abc')
        self.assertEqual(context['filename'].mimetype, 'x/foo')
        self.assertEqual(context['filename'].filename, 'filename')

        # attempt a duplicate upload
        self.assertRaises(ValidationError, controller.handle_submit, converted)
开发者ID:boothead,项目名称:karl,代码行数:33,代码来源:test_files.py


示例15: test_handle_submit_success

    def test_handle_submit_success(self):
        self._register()
        from zope.interface import directlyProvides
        from karl.models.interfaces import ISite
        from karl.models.interfaces import ICommunity
        from repoze.lemonade.interfaces import IContentFactory
        context = testing.DummyModel()
        directlyProvides(context, ISite)
        tags = context.tags = testing.DummyModel()
        _tagged = []
        def _update(item, user, tags):
            _tagged.append((item, user, tags))
        tags.update = _update
        testing.registerDummySecurityPolicy('userid')
        workflow = self._registerDummyWorkflow()
        testing.registerAdapter(lambda *arg: DummyCommunity,
                                (ICommunity,),
                                IContentFactory)
        dummy_tool_factory = DummyToolFactory()
        self._registerAddables([{'name':'blog', 'title':'blog',
                                 'component':dummy_tool_factory}])
        context.users = karltesting.DummyUsers({})
        context.catalog = karltesting.DummyCatalog({1:'/foo'})
        request = testing.DummyRequest()
        controller = self._makeOne(context, request)
        converted = {'title':'Thetitle yo',
                     'description':'thedescription',
                     'text':'thetext',
                     'tools': ['blog'],
                     'security_state': 'private',
                     'tags': ['foo'],
                     'default_tool': 'blog',
                     }
        result = controller.handle_submit(converted)
        rl = 'http://example.com/thetitle-yo/members/add_existing.html'
        self.failUnless(result.location.startswith(rl))
        community = context['thetitle-yo']
        self.assertEqual(community.title, 'Thetitle yo')
        self.assertEqual(community.description, 'thedescription')
        self.assertEqual(community.text, 'thetext')
        self.assertEqual(community.default_tool, 'blog')
        self.assertEqual(community.creator, 'userid')
        self.assertEqual(community.modified_by, 'userid')
        self.assertEqual(
            context.users.added_groups,
            [('userid', 'moderators'), ('userid', 'members') ]
        )
        self.assertEqual(dummy_tool_factory.added, True)
        self.assertEqual(len(_tagged), 1)
        self.assertEqual(_tagged[0][0], None)
        self.assertEqual(_tagged[0][1], 'userid')
        self.assertEqual(_tagged[0][2], ['foo'])
        self.assertEqual(workflow.transitioned[0]['to_state'], 'private')

        # try again w/ an invalid default_tool
        converted['title'] = 'Another title yo'
        converted['default_tool'] = 'wiki'
        result = controller.handle_submit(converted)
        community = context['another-title-yo']
        self.failUnless(community.default_tool is None)
开发者ID:cguardia,项目名称:karl,代码行数:60,代码来源:test_community.py


示例16: test_submitted_toobig

    def test_submitted_toobig(self):
        self._register()
        self._registerLayoutProvider()

        from repoze.bfg.formish import ValidationError

        def check_upload_size(*args):
            raise ValidationError(file='TEST VALIDATION ERROR')

        testing.registerDummySecurityPolicy('userid')
        context = self._makeContext()
        context.catalog = DummyCatalog()
        request = self._makeRequest()
        from schemaish.type import File as SchemaFile
        fs = SchemaFile('abc', 'filename', 'x/foo')
        converted = {
            'file': fs,
            'title': 'a title',
            'sendalert': False,
            'security_state': 'public',
            'tags':[],
            }
        from karl.content.interfaces import ICommunityFile
        from repoze.lemonade.testing import registerContentFactory
        registerContentFactory(DummyCommunityFile, ICommunityFile)
        controller = self._makeOne(context, request, check_upload_size)
        self.assertRaises(ValidationError, controller.handle_submit, converted)
开发者ID:boothead,项目名称:karl,代码行数:27,代码来源:test_files.py


示例17: test_handle_submit_titlechange

    def test_handle_submit_titlechange(self):
        from karl.testing import DummyCatalog

        self._register()
        converted = {
            "text": "text",
            "title": "newtitle",
            "sendalert": True,
            "security_state": "public",
            "tags": "thetesttag",
        }
        context = testing.DummyModel(title="oldtitle")
        context.text = "oldtext"

        def change_title(newtitle):
            context.title = newtitle

        context.change_title = change_title
        context.catalog = DummyCatalog()
        request = testing.DummyRequest()
        from karl.models.interfaces import IObjectModifiedEvent
        from zope.interface import Interface

        L = testing.registerEventListener((Interface, IObjectModifiedEvent))
        testing.registerDummySecurityPolicy("testeditor")
        controller = self._makeOne(context, request)
        response = controller.handle_submit(converted)
        self.assertEqual(L[0], context)
        self.assertEqual(L[1].object, context)
        self.assertEqual(response.location, "http://example.com/?status_message=Wiki%20Page%20edited")
        self.assertEqual(context.text, "text")
        self.assertEqual(context.modified_by, "testeditor")
        self.assertEqual(context.title, "newtitle")
开发者ID:cguardia,项目名称:karl,代码行数:33,代码来源:test_wiki.py


示例18: test_set_preferred_communities

 def test_set_preferred_communities(self):
     from zope.interface import Interface
     from opencore.models.interfaces import ICommunityInfo
     from opencore.views.communities import get_preferred_communities
     context = testing.DummyModel()
     yo = testing.DummyModel()
     yo.title = 'Yo'
     yi = testing.DummyModel()
     yi.title = 'Yi'
     context['yo'] = yo
     context['yi'] = yi
     profiles = context['profiles'] = testing.DummyModel()
     foo = profiles['foo'] = testing.DummyModel()
     foo.preferred_communities = None
     request = testing.DummyRequest()
     testing.registerDummySecurityPolicy(
         'foo',
         groupids=[
         'group.community:yo:members',
         'group.community:yo:moderators',
         'group.community:yi:moderators',
         'group.community:yang:moderators'
         ]
         )
     testing.registerAdapter(DummyAdapter, (Interface, Interface),
                             ICommunityInfo)
     communities = ['yi']
     self._callFUT(context, request, communities)
     result = get_preferred_communities(context, request)
     self.assertEqual(len(result), 1)
     self.assertEqual(result[0], 'yi')
开发者ID:lonetwin,项目名称:opencore,代码行数:31,代码来源:test_communities.py


示例19: test_w_overflow

 def test_w_overflow(self):
     from zope.interface import Interface
     from opencore.models.interfaces import ICommunityInfo
     context = testing.DummyModel()
     profiles = context['profiles'] = testing.DummyModel()
     profiles['foo'] = testing.DummyModel()
     yo = testing.DummyModel()
     yo.title = 'Yo'
     yi = testing.DummyModel()
     yi.title = 'Yi'
     context['yo'] = yo
     context['yi'] = yi
     request = testing.DummyRequest()
     testing.registerDummySecurityPolicy(
         'foo',
         groupids=[
         'group.community:yo:members',
         'group.community:yo:moderators',
         'group.community:yi:moderators',
         'group.community:yang:moderators'
         ]
         )
     testing.registerAdapter(DummyAdapter, (Interface, Interface),
                             ICommunityInfo)
     result = self._callFUT(context, request)
     self.assertEqual(len(result), 2)
     self.assertEqual(result[0].context, yi)
开发者ID:lonetwin,项目名称:opencore,代码行数:27,代码来源:test_communities.py


示例20: test_my_communities

 def test_my_communities(self):
     from zope.interface import Interface
     from karl.models.interfaces import ICommunityInfo
     from karl.models.interfaces import ICatalogSearch
     from karl.models.interfaces import ILetterManager
     from karl.models.adapters import CatalogSearch
     catalog = karltesting.DummyCatalog({1:'/foo'})
     testing.registerAdapter(DummyAdapter, (Interface, Interface),
                             ICommunityInfo)
     testing.registerAdapter(CatalogSearch, (Interface), ICatalogSearch)
     testing.registerAdapter(DummyLetterManager, Interface,
                             ILetterManager)
     testing.registerDummySecurityPolicy('admin',
                                         ['group.community:yum:bar'])
     context = testing.DummyModel()
     yum = testing.DummyModel()
     context['yum'] = yum
     yum.title = 'Yum!'
     context.catalog = catalog
     foo = testing.DummyModel()
     testing.registerModels({'/foo':foo})
     request = testing.DummyRequest(
         params={'titlestartswith':'A'})
     renderer = testing.registerDummyRenderer('templates/communities.pt')
     self._callFUT(context, request)
     self.assertEqual(len(renderer.communities), 1)
     self.assertEqual(renderer.communities[0].context, foo)
     self.failUnless(renderer.communities)
     self.failUnless(renderer.actions)
     self.failUnless(renderer.my_communities[0].context, yum)
开发者ID:boothead,项目名称:karl,代码行数:30,代码来源:test_communities.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python testing.registerModels函数代码示例发布时间:2022-05-26
下一篇:
Python testing.registerDummyRenderer函数代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap