Ejemplo n.º 1
0
    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, [])
Ejemplo n.º 2
0
    def test_communities(self):
        self._registerTagbox()
        self._registerCatalogSearch()

        from repoze.bfg.testing import DummyModel
        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, [
            {"title": "Community 1",
             "moderator": False,
             "url": "http://example.com/communities/community/",},
            {"title": "Community 2",
             "moderator": True,
             "url": "http://example.com/communities/community2/",},
        ])