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

Python tests.profile函数代码示例

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

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



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

示例1: test_for_user_active

    def test_for_user_active(self, get_current):
        """Checks the locale dashboard loads for a user associated with it."""
        get_current.return_value.domain = 'testserver'
        # Create user/group and add user to group.
        u = user(username='test', save=True)
        u.groups.add(self.g)
        profile(u).save()
        # Create site-wide and group announcements and dashboard.
        announcement().save()
        content = 'stardate 12341'
        announcement(group=self.g, content=content).save()

        # Log in and check response.
        self.client.login(username='test', password='testpass')
        response = self.client.get(reverse('dashboards.group',
                                           args=[self.g.pk]), follow=True)
        eq_(200, response.status_code)
        doc = pq(response.content)
        # The locale dash tab shows up.
        eq_(4, len(doc('#doc-tabs li')))
        # The locale dash tabs shows up and is active
        eq_(u'A group', doc('#doc-tabs li.active').text())
        # The subtitle shows French.
        eq_(u'Deutsch', doc('#main h2.subtitle').text())
        # The correct announcement shows up.
        self.assertContains(response, content)
开发者ID:AutomatedTester,项目名称:kitsune,代码行数:26,代码来源:test_templates.py


示例2: setUp

 def setUp(self):
     super(PasswordChangeTests, self).setUp()
     self.u = user(save=True)
     profile(user=self.u)
     self.url = reverse('users.pw_change')
     self.new_pw = 'fjdka387fvstrongpassword!'
     self.client.login(username=self.u.username, password='testpass')
开发者ID:LASarkar,项目名称:kitsune,代码行数:7,代码来源:test_templates.py


示例3: 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


示例4: test_for_user_active

    def test_for_user_active(self, get_current):
        """Checks the locale dashboard loads for a user associated with it.
        """
        get_current.return_value.domain = "testserver"
        # Create user/group and add user to group.
        u = user(username="test", save=True)
        u.groups.add(self.g)
        profile(user=u)
        # Create site-wide and group announcements and dashboard.
        announcement().save()
        content = "stardate 12341"
        announcement(group=self.g, content=content).save()

        # Log in and check response.
        self.client.login(username="test", password="testpass")
        response = self.client.get(reverse("dashboards.group", args=[self.g.pk]), follow=True)
        eq_(200, response.status_code)
        doc = pq(response.content)
        # The locale dash tab shows up.
        eq_(4, len(doc("#user-nav li")))
        # The locale dash tabs shows up and is active
        eq_(u"A group", doc("#user-nav li.selected").text())
        # The subtitle shows French.
        eq_(u"Deutsch", doc("article h2.subtitle").text())
        # The correct announcement shows up.
        self.assertContains(response, content)
开发者ID:atopal,项目名称:kitsune,代码行数:26,代码来源:test_templates.py


示例5: test_loggedin_preferred_language

    def test_loggedin_preferred_language(self):
        u = user(save=True)
        profile(user=u, locale="zh-CN")
        self.client.login(username=u.username, password="testpass")
        response = self.client.get("/", follow=True)
        self.assertRedirects(response, "/zh-CN/home")

        self.client.logout()
        response = self.client.get("/", follow=True, HTTP_ACCEPT_LANGUAGE="xx")
        self.assertRedirects(response, "/xx/home")
开发者ID:atopal,项目名称:kitsune,代码行数:10,代码来源:test_locale_middleware.py


示例6: test_POST

    def test_POST(self, get_current):
        get_current.return_value.domain = "testserver.com"
        u = user(save=True, email="[email protected]", is_active=True)
        profile(user=u)  # save=True is forced.

        r = self.client.post(reverse("users.forgot_username"), {"email": u.email})
        eq_(302, r.status_code)
        eq_("http://testserver/en-US/users/login", r["location"])

        # Verify email
        eq_(1, len(mail.outbox))
        assert mail.outbox[0].subject.find("Your username on") == 0
        assert mail.outbox[0].body.find(u.username) > 0
开发者ID:bituka,项目名称:kitsune,代码行数:13,代码来源:test_templates.py


示例7: _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


示例8: test_POST

    def test_POST(self, get_current):
        get_current.return_value.domain = 'testserver.com'
        u = user(save=True, email='[email protected]', is_active=True)
        profile(user=u)  # save=True is forced.

        r = self.client.post(reverse('users.forgot_username'),
                             {'email': u.email})
        eq_(302, r.status_code)
        eq_('http://testserver/en-US/users/login', r['location'])

        # Verify email
        eq_(1, len(mail.outbox))
        assert mail.outbox[0].subject.find('Your username on') == 0
        assert mail.outbox[0].body.find(u.username) > 0
开发者ID:LASarkar,项目名称:kitsune,代码行数:14,代码来源:test_templates.py


示例9: questionvote

def questionvote(**kwargs):
    defaults = dict(created=datetime.now())
    defaults.update(kwargs)
    if "question" not in kwargs and "queation_id" not in kwargs:
        defaults["question"] = question(save=True)
    if "creator" not in kwargs and "creator_id" not in kwargs:
        defaults["creator"] = profile().user
    return QuestionVote(**defaults)
开发者ID:atopal,项目名称:kitsune,代码行数:8,代码来源:__init__.py


示例10: test_anonymous_change_to_login

    def test_anonymous_change_to_login(self):
        u = user(save=True)
        profile(user=u, locale="zh-CN")

        # anonymous is fr
        self.client.get("/?lang=fr", follow=True)
        response = self.client.get("/", follow=True)
        self.assertRedirects(response, "/fr/home")

        # logged in is zh-CN
        self.client.login(username=u.username, password="testpass")
        response = self.client.get("/", follow=True)
        self.assertRedirects(response, "/zh-CN/home")

        # anonymous again, session is now destroyed
        self.client.logout()
        response = self.client.get("/", follow=True, HTTP_ACCEPT_LANGUAGE="xx")
        self.assertRedirects(response, "/xx/home")
开发者ID:atopal,项目名称:kitsune,代码行数:18,代码来源:test_locale_middleware.py


示例11: test_num_documents

    def test_num_documents(self):
        """Verify the number of documents contributed by user."""
        u = profile().user
        revision(creator=u, save=True)
        revision(creator=u, save=True)

        r = self.client.get(reverse('users.profile', args=[u.id]))
        eq_(200, r.status_code)
        assert '2 documents' in r.content
开发者ID:LASarkar,项目名称:kitsune,代码行数:9,代码来源:test_templates.py


示例12: setUp

 def setUp(self):
     self.timezone = timezone('US/Pacific')
     self.locale = 'en_US'
     url_ = reverse('forums.threads', args=['testslug'])
     self.context = {'request': test_utils.RequestFactory().get(url_)}
     self.context['request'].locale = self.locale
     user_profile = profile(timezone=self.timezone, locale=self.locale)
     self.context['request'].user = user_profile
     self.context['request'].user.is_authenticated = Mock(return_value=True)
     self.context['request'].session = {'timezone': self.timezone}
开发者ID:Disabledpeople,项目名称:kitsune,代码行数:10,代码来源:test_helpers.py


示例13: test_ga_custom_variable_on_registered_login

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

        # User should be "Registered":
        response = self.client.post(
            reverse("users.login"), {"username": user_.username, "password": "testpass"}, follow=True
        )
        eq_(200, response.status_code)
        doc = pq(response.content)
        assert '"Registered"' in doc("body").attr("data-ga-push")
开发者ID:bituka,项目名称:kitsune,代码行数:11,代码来源:test_templates.py


示例14: 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


示例15: test_ga_custom_variable_on_registered_login

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

        # User should be "Registered":
        response = self.client.post(reverse('users.login'),
                                    {'username': user_.username,
                                     'password': 'testpass'},
                                    follow=True)
        eq_(200, response.status_code)
        doc = pq(response.content)
        assert '"Registered"' in doc('body').attr('data-ga-push')
开发者ID:LASarkar,项目名称:kitsune,代码行数:12,代码来源:test_templates.py


示例16: 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


示例17: test_flagged_and_deleted_profile

    def test_flagged_and_deleted_profile(self):
        u = user(save=True)
        p = profile(user=u)
        flag_user = user(save=True)
        # Flag a profile and delete it
        f = FlaggedObject(content_object=p, reason="spam", creator_id=flag_user.id)
        f.save()
        p.delete()

        # Verify flagit queue
        u = user(save=True)
        add_permission(u, FlaggedObject, "can_moderate")
        self.client.login(username=u.username, password="testpass")
        response = get(self.client, "flagit.queue")
        eq_(200, response.status_code)
        doc = pq(response.content)
        eq_(1, len(doc("#flagged-queue form.update")))
开发者ID:bituka,项目名称:kitsune,代码行数:17,代码来源:test_templates.py


示例18: test_profile_deactivate

    def test_profile_deactivate(self):
        """Test user deactivation"""
        p = profile()

        self.client.login(username=self.u.username, password='testpass')
        res = self.client.post(reverse('users.deactivate', locale='en-US'),
                               {'user_id': p.user.id})

        eq_(403, res.status_code)

        add_permission(self.u, Profile, 'deactivate_users')
        res = self.client.post(reverse('users.deactivate', locale='en-US'),
                               {'user_id': p.user.id})

        eq_(302, res.status_code)

        p = Profile.objects.get(user_id=p.user_id)
        assert not p.user.is_active
开发者ID:bajubullet,项目名称:kitsune,代码行数:18,代码来源:test_views.py


示例19: test_deactivate_button

    def test_deactivate_button(self):
        """Check that the deactivate button is shown appropriately"""
        p = profile()
        r = self.client.get(reverse('users.profile', args=[p.user.id]))
        assert 'Deactivate this user' not in r.content

        add_permission(self.u, Profile, 'deactivate_users')
        self.client.login(username=self.u.username, password='testpass')
        r = self.client.get(reverse('users.profile', args=[p.user.id]))
        assert 'Deactivate this user' in r.content

        p.user.is_active = False
        p.user.save()
        r = self.client.get(reverse('users.profile', args=[p.user.id]))
        assert 'This user has been deactivated.' in r.content

        r = self.client.get(reverse('users.profile', args=[self.u.id]))
        assert 'Deactivate this user' not in r.content
开发者ID:LASarkar,项目名称:kitsune,代码行数:18,代码来源:test_templates.py


示例20: test_display_name

 def test_display_name(self):
     eq_(u'testuser', display_name(self.u))
     p = profile(user=self.u, name=u'Test User')
     eq_(u'Test User', display_name(self.u))
开发者ID:DWDRAEGER,项目名称:kitsune,代码行数:4,代码来源:test_helpers.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python tests.user函数代码示例发布时间:2022-05-27
下一篇:
Python tests.group函数代码示例发布时间: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