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

Python tests.group函数代码示例

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

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



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

示例1: test_new_contributor

    def test_new_contributor(self, get_current):
        """Verify that interested contributors are added to group."""
        get_current.return_value.domain = 'su.mo.com'
        group_name = 'Registered as contributor'
        group(name=group_name, save=True)
        data = {
            'username': 'newbie',
            'email': '[email protected]',
            'password': 'foobar22',
            'password2': 'foobar22',
            'interested': 'yes'}
        response = self.client.post(reverse('users.register', locale='en-US'),
                                    data, follow=True)
        eq_(200, response.status_code)
        u = User.objects.get(username='newbie')
        eq_(group_name, u.groups.all()[0].name)

        # Activate user and verify email is sent.
        key = RegistrationProfile.objects.all()[0].activation_key
        url = reverse('users.activate', args=[u.id, key])
        response = self.client.get(url, follow=True)
        eq_(200, response.status_code)
        eq_(2, len(mail.outbox))
        assert mail.outbox[1].subject.find('Welcome to') == 0
        assert u.username in mail.outbox[1].body
开发者ID:icaaq,项目名称:kitsune,代码行数:25,代码来源:test_views.py


示例2: test_right_group_profile

    def test_right_group_profile(self):
        """Make sure we get the right group profile."""
        g1 = group(pk=100)
        g1.save()
        eq_(100, g1.pk)
        g2 = group(pk=101)
        g2.save()
        eq_(101, g2.pk)
        p = GroupProfile.objects.create(pk=100, group=g2, slug='foo')
        eq_(100, p.pk)

        eq_(group_link(g1), g1.name)
开发者ID:Apokalyptica79,项目名称:kitsune,代码行数:12,代码来源:test_helpers.py


示例3: test_new_contributor

 def test_new_contributor(self, get_current):
     """Verify that interested contributors are added to group."""
     get_current.return_value.domain = 'su.mo.com'
     group_name = 'Registered as contributor'
     group(name=group_name, save=True)
     data = {
         'username': 'newbie',
         'email': '[email protected]',
         'password': 'foobar22',
         'password2': 'foobar22',
         'interested': 'yes'}
     response = self.client.post(reverse('users.register', locale='en-US'),
                                 data, follow=True)
     eq_(200, response.status_code)
     u = User.objects.get(username='newbie')
     eq_(group_name, u.groups.all()[0].name)
开发者ID:Meghashyamt,项目名称:kitsune,代码行数:16,代码来源:test_views.py


示例4: test_delete_post_belongs_to_thread_and_forum

    def test_delete_post_belongs_to_thread_and_forum(self):
        """
        Delete post action - post belongs to thread and thread belongs to
        forum.
        """
        f = forum(save=True)
        t = thread(forum=f, save=True)
        # Post belongs to a different forum and thread.
        p = forum_post(save=True)
        u = p.author

        # Give the user the permission to delete posts.
        g = group(save=True)
        ct = ContentType.objects.get_for_model(f)
        permission(codename='forums_forum.post_delete_forum',
                   content_type=ct, object_id=p.thread.forum_id, group=g,
                   save=True)
        permission(codename='forums_forum.post_delete_forum',
                   content_type=ct, object_id=f.id, group=g, save=True)
        g.user_set.add(u)

        self.client.login(username=u.username, password='testpass')

        # Post isn't in the passed forum:
        r = get(self.client, 'forums.delete_post',
                args=[f.slug, p.thread.id, p.id])
        eq_(404, r.status_code)

        # Post isn't in the passed thread:
        r = get(self.client, 'forums.delete_post',
                args=[p.thread.forum.slug, t.id, p.id])
        eq_(404, r.status_code)
开发者ID:Apokalyptica79,项目名称:kitsune,代码行数:32,代码来源:test_urls.py


示例5: setUp

 def setUp(self):
     super(AnnouncementModelTests, self).setUp()
     self.creator = user(save=True)
     profile(user=self.creator)
     self.group = group(save=True)
     self.locale = locale(locale='es', save=True)
     self.creator.groups.add(self.group)
开发者ID:DWDRAEGER,项目名称:kitsune,代码行数:7,代码来源:test_models.py


示例6: setUp

 def setUp(self):
     super(AddRemoveLeaderTests, self).setUp()
     self.user = user(save=True)
     add_permission(self.user, GroupProfile, 'change_groupprofile')
     self.leader = user(save=True)
     self.group_profile = group_profile(group=group(save=True), save=True)
     self.client.login(username=self.user.username, password='testpass')
开发者ID:Apokalyptica79,项目名称:kitsune,代码行数:7,代码来源:test_views.py


示例7: setUp

    def setUp(self):
        url = reverse('forums.threads', args=[u'test-forum'])
        self.context = {'request': test_utils.RequestFactory().get(url)}

        self.group = group(save=True)

        # Set up forum_1
        f = self.forum_1 = forum(save=True)
        ct = ContentType.objects.get_for_model(self.forum_1)
        permission(codename='forums_forum.thread_edit_forum', content_type=ct,
                   object_id=f.id, group=self.group, save=True)
        permission(codename='forums_forum.post_edit_forum', content_type=ct,
                   object_id=f.id, group=self.group, save=True)
        permission(codename='forums_forum.post_delete_forum', content_type=ct,
                   object_id=f.id, group=self.group, save=True)
        permission(codename='forums_forum.thread_delete_forum',
                   content_type=ct, object_id=f.id, group=self.group,
                   save=True)
        permission(codename='forums_forum.thread_sticky_forum',
                   content_type=ct, object_id=f.id, group=self.group,
                   save=True)
        permission(codename='forums_forum.thread_move_forum', content_type=ct,
                   object_id=f.id, group=self.group, save=True)

        # Set up forum_2
        f = self.forum_2 = forum(save=True)
        permission(codename='forums_forum.thread_move_forum', content_type=ct,
                   object_id=f.id, group=self.group, save=True)
开发者ID:DWDRAEGER,项目名称:kitsune,代码行数:28,代码来源:test_permissions.py


示例8: test_group_link_with_profile

 def test_group_link_with_profile(self):
     g = group()
     g.save()
     p = GroupProfile.objects.create(group=g, slug='foo')
     text = group_link(g)
     doc = pq(text)
     eq_(reverse('groups.profile', args=[p.slug]),
         doc('a')[0].attrib['href'])
     eq_(g.name, doc('a')[0].text)
开发者ID:Apokalyptica79,项目名称:kitsune,代码行数:9,代码来源:test_helpers.py


示例9: test_group_avatar

 def test_group_avatar(self):
     g = group()
     g.save()
     p = GroupProfile.objects.create(group=g, slug='foo')
     url = group_avatar(p)
     eq_(settings.DEFAULT_AVATAR, url)
     p.avatar = Mock()
     p.avatar.url = '/foo/bar'
     url = group_avatar(p)
     eq_('/foo/bar', url)
开发者ID:Apokalyptica79,项目名称:kitsune,代码行数:10,代码来源:test_helpers.py


示例10: test_personal_dashboards

    def test_personal_dashboards(self):
        """Just run through it to make sure there aren't obvious explosions."""
        g = group(name='winners', save=True)
        g2 = group(name='losers', save=True)
        u = user(save=True)
        u.groups.add(g)
        u.groups.add(g2)

        GroupDashboard.objects.create(group=g, dashboard='sea', parameters='1')
        GroupDashboard.objects.create(group=g2, dashboard='sea',
                                      parameters='3')

        class MockRequest(object):
            user = u

        request = MockRequest()
        dashes = personal_dashboards(request)
        # Sort order of the two ATestDashboards is by group name.
        eq_(2, len(dashes))
        eq_('3', dashes[0].parameters)
        eq_(g, dashes[1].group)
开发者ID:Akamad007,项目名称:kitsune,代码行数:21,代码来源:test_personal.py


示例11: test_ga_custom_variable_on_admin_login

    def test_ga_custom_variable_on_admin_login(self):
        """After logging in, there should be a ga-push data attr on body."""
        user_ = profile().user

        # Add user to Administrators and so should be "Contributor - Admin":
        user_.groups.add(group(name="Administrators", save=True))
        response = self.client.post(
            reverse("users.login"), {"username": user_.username, "password": "testpass"}, follow=True
        )
        eq_(200, response.status_code)
        doc = pq(response.content)
        assert '"Contributor - Admin"' in doc("body").attr("data-ga-push")
开发者ID:bituka,项目名称:kitsune,代码行数:12,代码来源:test_templates.py


示例12: setUp

 def setUp(self):
     super(HelpfulVotesGraphTests, self).setUp()
     self.user = user(save=True)
     self.client.login(username=self.user.username, password='testpass')
     self.group = group(name='Contributors', save=True)
     # Without this, there were unrelated failures with l10n dashboard
     self.REDIS_KEY = settings.HELPFULVOTES_UNHELPFUL_KEY
     try:
         self.redis = redis_client('helpfulvotes')
         self.redis.flushdb()
     except RedisError:
         raise SkipTest
开发者ID:LASarkar,项目名称:kitsune,代码行数:12,代码来源:test_views.py


示例13: test_ga_custom_variable_on_contributor_login

    def test_ga_custom_variable_on_contributor_login(self):
        """After logging in, there should be a ga-push data attr on body."""
        user_ = profile().user

        # Add user to Contributors and so should be "Contributor":
        user_.groups.add(group(name='Contributors', save=True))
        response = self.client.post(reverse('users.login'),
                                    {'username': user_.username,
                                     'password': 'testpass'},
                                    follow=True)
        eq_(200, response.status_code)
        doc = pq(response.content)
        assert '"Contributor"' in doc('body').attr('data-ga-push')
开发者ID:LASarkar,项目名称:kitsune,代码行数:13,代码来源:test_templates.py


示例14: _setup_announcement

    def _setup_announcement(self, visible_dates=True):
        g = group(save=True)
        u1 = user(save=True)
        u2 = user(save=True)
        u1.groups.add(g)
        u2.groups.add(g)
        # Create profiles for these users
        profile(user=u1)
        profile(user=u2)
        self.user = u2

        return announcement(creator=u1, group=g, save=True,
                            visible_dates=visible_dates)
开发者ID:Apokalyptica79,项目名称:kitsune,代码行数:13,代码来源:test_tasks.py


示例15: test_edit_thread_moderator

    def test_edit_thread_moderator(self):
        """Editing post as a moderator works."""
        t = forum_post(save=True).thread
        f = t.forum
        u = user(save=True)
        g = group(save=True)
        ct = ContentType.objects.get_for_model(f)
        permission(codename='forums_forum.thread_edit_forum', content_type=ct,
                   object_id=f.id, group=g, save=True)
        g.user_set.add(u)

        self.client.login(username=u.username, password='testpass')
        r = post(self.client, 'forums.edit_thread',
                 {'title': 'new title'}, args=[f.slug, t.id])
        eq_(200, r.status_code)
        edited_t = Thread.uncached.get(id=t.id)
        eq_('new title', edited_t.title)
开发者ID:Apokalyptica79,项目名称:kitsune,代码行数:17,代码来源:test_views.py


示例16: test_delete_thread_belongs_to_forum

    def test_delete_thread_belongs_to_forum(self):
        """Delete thread action - thread belongs to forum."""
        f = forum(save=True)
        t = thread(save=True)  # Thread belongs to a different forum
        u = user(save=True)

        # Give the user the permission to delete threads.
        g = group(save=True)
        ct = ContentType.objects.get_for_model(f)
        permission(codename='forums_forum.thread_delete_forum',
                   content_type=ct, object_id=f.id, group=g, save=True)
        permission(codename='forums_forum.thread_delete_forum',
                   content_type=ct, object_id=t.forum.id, group=g, save=True)
        g.user_set.add(u)

        self.client.login(username=u.username, password='testpass')
        r = get(self.client, 'forums.delete_thread', args=[f.slug, t.id])
        eq_(404, r.status_code)
开发者ID:Apokalyptica79,项目名称:kitsune,代码行数:18,代码来源:test_urls.py


示例17: test_move_thread

    def test_move_thread(self):
        """Move a thread."""
        t = forum_post(save=True).thread
        f = forum(save=True)
        u = user(save=True)
        g = group(save=True)

        # Give the user permission to move threads between the two forums.
        ct = ContentType.objects.get_for_model(f)
        permission(codename='forums_forum.thread_move_forum', content_type=ct,
                   object_id=f.id, group=g, save=True)
        permission(codename='forums_forum.thread_move_forum', content_type=ct,
                   object_id=t.forum.id, group=g, save=True)
        g.user_set.add(u)

        self.client.login(username=u.username, password='testpass')
        response = post(self.client, 'forums.move_thread',
                        {'forum': f.id},
                        args=[t.forum.slug, t.id])
        eq_(200, response.status_code)
        t = Thread.uncached.get(pk=t.pk)
        eq_(f.id, t.forum.id)
开发者ID:Apokalyptica79,项目名称:kitsune,代码行数:22,代码来源:test_views.py


示例18: test_edit_post_moderator

    def test_edit_post_moderator(self):
        """Editing post as a moderator works."""
        p = forum_post(save=True)
        t = p.thread
        f = t.forum

        # Create the moderator group, give it the edit permission
        # and add a moderator.
        moderator_group = group(save=True)
        ct = ContentType.objects.get_for_model(f)
        permission(codename='forums_forum.post_edit_forum', content_type=ct,
                   object_id=f.id, group=moderator_group, save=True)
        moderator = user(save=True)
        moderator_group.user_set.add(moderator)

        self.client.login(username=moderator.username, password='testpass')

        r = post(self.client, 'forums.edit_post',
                 {'content': 'More new content'}, args=[f.slug, t.id, p.id])
        eq_(200, r.status_code)

        edited_p = Post.uncached.get(pk=p.pk)
        eq_('More new content', edited_p.content)
开发者ID:LASarkar,项目名称:kitsune,代码行数:23,代码来源:test_templates.py


示例19: setUp

 def setUp(self):
     super(GroupLocaleDashTests, self).setUp()
     self.g = group(save=True, name='A group')
     # defaults to a 'de' localization dashboard
     group_dashboard(group=self.g, save=True)
开发者ID:AutomatedTester,项目名称:kitsune,代码行数:5,代码来源:test_templates.py


示例20: setUp

 def setUp(self):
     super(DefaultDashboardRedirect, self).setUp()
     self.user = user(save=True)
     self.client.login(username=self.user.username, password='testpass')
     self.group = group(name='Contributors', save=True)
开发者ID:Curlified,项目名称:kitsune,代码行数:5,代码来源:test_views.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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