當前位置: 首頁>>代碼示例>>Python>>正文


Python factories.GroupFactory類代碼示例

本文整理匯總了Python中machina.test.factories.GroupFactory的典型用法代碼示例。如果您正苦於以下問題:Python GroupFactory類的具體用法?Python GroupFactory怎麽用?Python GroupFactory使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了GroupFactory類的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: setup

    def setup(self):
        self.loadstatement = '{% load forum_permission_tags %}'
        self.request_factory = RequestFactory()

        self.g1 = GroupFactory.create()
        self.u1 = UserFactory.create()
        self.u2 = UserFactory.create()
        self.u1.groups.add(self.g1)
        self.u2.groups.add(self.g1)
        self.moderators = GroupFactory.create()
        self.moderator = UserFactory.create()
        self.moderator.groups.add(self.moderators)
        self.superuser = UserFactory.create(is_superuser=True)

        # Permission handler
        self.perm_handler = PermissionHandler()

        # Set up a top-level category
        self.top_level_cat = create_category_forum()

        # Set up some forums
        self.forum_1 = create_forum(parent=self.top_level_cat)
        self.forum_2 = create_forum(parent=self.top_level_cat)

        # Set up some topics and posts
        self.forum_1_topic = create_topic(forum=self.forum_1, poster=self.u1)
        self.forum_2_topic = create_topic(forum=self.forum_2, poster=self.u2)
        self.post_1 = PostFactory.create(topic=self.forum_1_topic, poster=self.u1)
        self.post_2 = PostFactory.create(topic=self.forum_2_topic, poster=self.u2)
開發者ID:harish211,項目名稱:django-machina,代碼行數:29,代碼來源:test_permission_tags.py

示例2: test_knows_that_granted_permissions_should_take_precedence_over_the_same_non_granted_permissions

 def test_knows_that_granted_permissions_should_take_precedence_over_the_same_non_granted_permissions(self):  # noqa: E501
     # Setup
     user = UserFactory.create()
     group_all_users = GroupFactory.create()
     group_specific_access = GroupFactory.create()
     user.groups.add(group_all_users)
     user.groups.add(group_specific_access)
     assign_perm('can_read_forum', group_all_users, None)  # global permission
     assign_perm('can_read_forum', group_all_users, self.forum, has_perm=False)
     assign_perm('can_read_forum', group_specific_access, self.forum, has_perm=True)
     checker = ForumPermissionChecker(user)
     # Run & check
     assert checker.has_perm('can_read_forum', self.forum)
開發者ID:ellmetha,項目名稱:django-machina,代碼行數:13,代碼來源:test_checker.py

示例3: setup

    def setup(self):
        # Add some users
        self.u1 = UserFactory.create()
        self.g1 = GroupFactory.create()
        self.u1.groups.add(self.g1)
        self.user.groups.add(self.g1)

        # Permission handler
        self.perm_handler = PermissionHandler()

        self.top_level_cat_1 = create_category_forum()

        self.forum_1 = create_forum(parent=self.top_level_cat_1)
        self.forum_2 = create_forum(parent=self.top_level_cat_1)
        self.forum_3 = create_forum(parent=self.top_level_cat_1)

        self.topic_1 = create_topic(forum=self.forum_2, poster=self.u1)
        PostFactory.create(topic=self.topic_1, poster=self.u1)
        PostFactory.create(topic=self.topic_1, poster=self.user)

        self.topic_2 = create_topic(forum=self.forum_1, poster=self.user)
        PostFactory.create(topic=self.topic_2, poster=self.user)
        PostFactory.create(topic=self.topic_2, poster=self.u1)

        self.topic_3 = create_topic(forum=self.forum_2, poster=self.u1)
        PostFactory.create(topic=self.topic_3, poster=self.u1)

        self.topic_4 = create_topic(forum=self.forum_2, poster=self.user)
        PostFactory.create(topic=self.topic_4, poster=self.user)

        # Assign some permissions
        assign_perm('can_read_forum', self.g1, self.top_level_cat_1)
        assign_perm('can_read_forum', self.g1, self.forum_1)
        assign_perm('can_read_forum', self.g1, self.forum_2)
開發者ID:squamous,項目名稱:django-machina,代碼行數:34,代碼來源:test_views.py

示例4: setUp

    def setUp(self):
        self.loadstatement = '{% load forum_tracking_tags %}'
        self.request_factory = RequestFactory()

        # Tracking handler
        self.tracks_handler = TrackingHandler()

        self.g1 = GroupFactory.create()
        self.u1 = UserFactory.create()
        self.u2 = UserFactory.create()
        self.u1.groups.add(self.g1)
        self.u2.groups.add(self.g1)

        # Set up a top-level category
        self.top_level_cat = create_category_forum()

        # Set up some forums
        self.forum_1 = create_forum(parent=self.top_level_cat)
        self.forum_2 = create_forum(parent=self.top_level_cat)

        # Set up some topics and posts
        self.forum_1_topic = create_topic(forum=self.forum_1, poster=self.u1)
        self.forum_2_topic = create_topic(forum=self.forum_2, poster=self.u1)
        self.post_1 = PostFactory.create(topic=self.forum_1_topic, poster=self.u1)
        self.post_2 = PostFactory.create(topic=self.forum_2_topic, poster=self.u1)

        # Assign some permissions
        assign_perm('can_see_forum', self.g1, self.top_level_cat)
        assign_perm('can_read_forum', self.g1, self.top_level_cat)
        assign_perm('can_see_forum', self.g1, self.forum_1)
        assign_perm('can_read_forum', self.g1, self.forum_1)
        assign_perm('can_see_forum', self.g1, self.forum_2)
        assign_perm('can_read_forum', self.g1, self.forum_2)
開發者ID:DrJackilD,項目名稱:django-machina,代碼行數:33,代碼來源:test_tracking_tags.py

示例5: setup

    def setup(self):
        self.u1 = UserFactory.create()
        self.g1 = GroupFactory.create()
        self.u1.groups.add(self.g1)

        # Permission handler
        self.perm_handler = PermissionHandler()

        # Set up a top-level category
        self.top_level_cat = create_category_forum()

        # Set up some forums
        self.forum_1 = create_forum(parent=self.top_level_cat)
        self.forum_2 = create_forum(parent=self.top_level_cat)
        self.forum_3 = create_link_forum(parent=self.top_level_cat)

        # Set up a top-level forum link
        self.top_level_link = create_link_forum()

        # Set up some topics
        self.forum_1_topic = create_topic(forum=self.forum_1, poster=self.u1)
        self.forum_3_topic = create_topic(forum=self.forum_3, poster=self.u1)
        self.forum_3_topic_2 = create_topic(
            forum=self.forum_3, poster=self.u1, status=Topic.TOPIC_LOCKED)

        # Set up some posts
        self.post_1 = PostFactory.create(topic=self.forum_1_topic, poster=self.u1)
        self.post_2 = PostFactory.create(topic=self.forum_3_topic, poster=self.u1)

        # Assign some permissions
        assign_perm('can_see_forum', self.u1, self.top_level_cat)
        assign_perm('can_see_forum', self.u1, self.forum_1)
        assign_perm('can_read_forum', self.g1, self.forum_3)
開發者ID:swcheon,項目名稱:django-machina,代碼行數:33,代碼來源:test_handler.py

示例6: setup

    def setup(self):
        self.loadstatement = '{% load forum_polls_tags %}'
        self.request_factory = RequestFactory()

        self.g1 = GroupFactory.create()
        self.u1 = UserFactory.create()
        self.u2 = UserFactory.create()
        self.u1.groups.add(self.g1)
        self.u2.groups.add(self.g1)
        self.moderators = GroupFactory.create()
        self.moderator = UserFactory.create()
        self.moderator.groups.add(self.moderators)
        self.superuser = UserFactory.create(is_superuser=True)

        # Permission handler
        self.perm_handler = PermissionHandler()

        # Set up a top-level category
        self.top_level_cat = create_category_forum()

        # Set up some forums
        self.forum_1 = create_forum(parent=self.top_level_cat)
        self.forum_2 = create_forum(parent=self.top_level_cat)

        # Set up some topics and posts
        self.forum_1_topic = create_topic(forum=self.forum_1, poster=self.u1)
        self.forum_2_topic = create_topic(forum=self.forum_2, poster=self.u2)
        self.post_1 = PostFactory.create(topic=self.forum_1_topic, poster=self.u1)
        self.post_2 = PostFactory.create(topic=self.forum_2_topic, poster=self.u2)
        self.poll_1 = TopicPollFactory.create(topic=self.forum_1_topic)
        self.poll_2 = TopicPollFactory.create(topic=self.forum_2_topic)

        # Assign some permissions
        assign_perm('can_see_forum', self.g1, self.forum_1)
        assign_perm('can_read_forum', self.g1, self.forum_1)
        assign_perm('can_edit_own_posts', self.g1, self.forum_1)
        assign_perm('can_delete_own_posts', self.g1, self.forum_1)
        assign_perm('can_reply_to_topics', self.g1, self.forum_1)
        assign_perm('can_see_forum', self.moderators, self.forum_1)
        assign_perm('can_read_forum', self.moderators, self.forum_1)
        assign_perm('can_edit_own_posts', self.moderators, self.forum_1)
        assign_perm('can_delete_own_posts', self.moderators, self.forum_1)
        assign_perm('can_edit_posts', self.moderators, self.forum_1)
        assign_perm('can_delete_posts', self.moderators, self.forum_1)
        assign_perm('can_vote_in_polls', self.g1, self.forum_1)
開發者ID:ellmetha,項目名稱:django-machina,代碼行數:45,代碼來源:test_polls_tags.py

示例7: test_knows_that_user_permissions_take_precedence_over_group_permissions

 def test_knows_that_user_permissions_take_precedence_over_group_permissions(self):
     # Setup
     user = UserFactory.create()
     group = GroupFactory.create()
     user.groups.add(group)
     assign_perm('can_read_forum', user, self.forum, has_perm=False)
     assign_perm('can_read_forum', group, self.forum, has_perm=True)
     checker = ForumPermissionChecker(user)
     # Run & check
     assert not checker.has_perm('can_read_forum', self.forum)
開發者ID:ellmetha,項目名稱:django-machina,代碼行數:10,代碼來源:test_checker.py

示例8: test_editpermission_index_view_can_redirect_to_group_permissions_form

 def test_editpermission_index_view_can_redirect_to_group_permissions_form(self):
     # Setup
     group = GroupFactory.create()
     model = self.model
     raw_url = 'admin:{}_{}_editpermission_index'.format(model._meta.app_label, self._get_module_name(model._meta))
     # Run
     url = reverse(raw_url, kwargs={'forum_id': self.top_level_cat.id})
     response = self.client.post(url, {'group': group.id}, follow=True)
     # Check
     editpermissions_group_raw_url = 'admin:{}_{}_editpermission_group'.format(
         model._meta.app_label, self._get_module_name(model._meta))
     editpermissions_group_url = reverse(editpermissions_group_raw_url, kwargs={
         'forum_id': self.top_level_cat.id, 'group_id': self.user.id})
     assert len(response.redirect_chain)
     last_url, status_code = response.redirect_chain[-1]
     assert editpermissions_group_url in last_url
開發者ID:squamous,項目名稱:django-machina,代碼行數:16,代碼來源:test_forum.py

示例9: test_editpermission_index_view_can_copy_permissions_from_another_forum

    def test_editpermission_index_view_can_copy_permissions_from_another_forum(self):
        # Setup
        group = GroupFactory.create()
        model = self.model

        UserForumPermissionFactory.create(
            permission=ForumPermission.objects.get(codename='can_see_forum'),
            forum=self.sub_forum_1,
            user=self.user, has_perm=False)
        UserForumPermissionFactory.create(
            permission=ForumPermission.objects.get(codename='can_read_forum'),
            forum=self.sub_forum_1,
            user=self.user, has_perm=True)
        UserForumPermissionFactory.create(
            permission=ForumPermission.objects.get(codename='can_start_new_topics'),
            forum=self.sub_forum_1,
            user=self.user, has_perm=False)
        GroupForumPermissionFactory.create(
            permission=ForumPermission.objects.get(codename='can_start_new_topics'),
            forum=self.sub_forum_1,
            group=group, has_perm=False)

        raw_url = 'admin:{}_{}_editpermission_index'.format(
            model._meta.app_label, self._get_module_name(model._meta))
        # Run
        url = reverse(raw_url, kwargs={'forum_id': self.top_level_cat.id})
        response = self.client.post(url, {'forum': self.sub_forum_1.id})
        # Check
        assert response.status_code == 200
        assert UserForumPermission.objects.filter(
            permission__codename='can_see_forum', forum=self.top_level_cat,
            user=self.user, has_perm=False).exists()
        assert UserForumPermission.objects.filter(
            permission__codename='can_read_forum', forum=self.top_level_cat,
            user=self.user, has_perm=True).exists()
        assert UserForumPermission.objects.filter(
            permission__codename='can_start_new_topics', forum=self.top_level_cat,
            user=self.user, has_perm=False).exists()
        assert GroupForumPermission.objects.filter(
            permission__codename='can_start_new_topics', forum=self.top_level_cat,
            group=group, has_perm=False).exists()
開發者ID:ashwin31,項目名稱:django-machina,代碼行數:41,代碼來源:test_forum.py

示例10: test_editpermission_form_can_update_group_permissions

 def test_editpermission_form_can_update_group_permissions(self):
     # Setup
     group = GroupFactory.create()
     model = self.model
     raw_url = 'admin:{}_{}_editpermission_group'.format(model._meta.app_label, self._get_module_name(model._meta))
     post_data = {
         'can_see_forum': 'granted',
         'can_read_forum': 'not-granted',
         'can_start_new_topics': 'not-set',
         'can_reply_to_topics': 'not-set',
         'can_post_announcements': 'not-set',
         'can_post_stickies': 'not-set',
         'can_delete_own_posts': 'not-set',
         'can_edit_own_posts': 'not-set',
         'can_post_without_approval': 'not-set',
         'can_create_polls': 'not-set',
         'can_vote_in_polls': 'not-set',
         'can_attach_file': 'not-set',
         'can_download_file': 'not-set',
         'can_lock_topics': 'not-set',
         'can_edit_posts': 'not-set',
         'can_delete_posts': 'not-set',
         'can_move_posts': 'not-set',
         'can_approve_posts': 'not-set',
     }
     # Run
     url = reverse(raw_url, kwargs={
         'forum_id': self.top_level_cat.id, 'group_id': group.id})
     response = self.client.post(url, post_data)
     # Check
     assert response.status_code == 200
     granted_perm = GroupForumPermission.objects.filter(
         permission__codename='can_see_forum', has_perm=True,
         group=group, forum=self.top_level_cat)
     assert granted_perm.exists()
     not_granted_perm = GroupForumPermission.objects.filter(
         permission__codename='can_read_forum', has_perm=False,
         group=group, forum=self.top_level_cat)
     assert not_granted_perm.exists()
開發者ID:harish211,項目名稱:django-machina,代碼行數:39,代碼來源:test_forum.py


注:本文中的machina.test.factories.GroupFactory類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。