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

Python tests.user函数代码示例

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

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



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

示例1: setUp

    def setUp(self, switch_is_active):
        switch_is_active.return_value = True

        super(KarmaAPITests, self).setUp()

        try:
            self.mgr = KarmaManager()
            redis_client('karma').flushdb()
        except RedisError:
            raise SkipTest

        self.user1 = user(save=True)
        self.user2 = user(save=True)
        self.user3 = user(save=True)

        TestAction1(user=self.user1).save()
        TestAction2(user=self.user2).save()
        TestAction2(user=self.user2).save()
        TestAction1(user=self.user3).save()
        TestAction1(user=self.user3).save()
        TestAction1(user=self.user3).save()
        self.mgr.update_top()

        self.client.login(username=self.user1.username, password='testpass')
        add_permission(self.user1, models.Title, 'view_dashboard')
开发者ID:Apokalyptica79,项目名称:kitsune,代码行数:25,代码来源:test_api.py


示例2: setUp

 def setUp(self):
     super(AddRemoveLeaderTests, self).setUp()
     self.locale = locale(locale='es', save=True)
     self.user = user(save=True)
     add_permission(self.user, Locale, 'change_locale')
     self.leader = user(save=True)
     self.client.login(username=self.user.username, password='testpass')
开发者ID:DWDRAEGER,项目名称:kitsune,代码行数:7,代码来源:test_locale_views.py


示例3: test_active_answerers

    def test_active_answerers(self):
        """Test active answerers API call."""
        # A user with 10 answers
        u1 = user(save=True)
        for x in range(10):
            answer(save=True, creator=u1)

        # A user with 9 answers
        u2 = user(save=True)
        for x in range(9):
            answer(save=True, creator=u2)

        # A user with 1 answer
        u3 = user(save=True)
        answer(save=True, creator=u3)

        # There should be only one active contributor.
        url = reverse('api_dispatch_list',
                      kwargs={'resource_name': 'kpi_active_answerers',
                              'api_name': 'v1'})

        response = self.client.get(url + '?format=json')
        eq_(200, response.status_code)
        r = json.loads(response.content)
        eq_(r['objects'][0]['contributors'], 1)
开发者ID:trinaldi,项目名称:kitsune,代码行数:25,代码来源:test_api.py


示例4: test_for_user_not_in_group

 def test_for_user_not_in_group(self):
     """Checks the locale dashboard doesn't load for user not in group."""
     user(username='test', save=True)
     self.client.login(username='test', password='testpass')
     response = self.client.get(reverse('dashboards.group',
                                        args=[self.g.pk], locale='en-US'))
     eq_(404, response.status_code)
开发者ID:AutomatedTester,项目名称:kitsune,代码行数:7,代码来源:test_templates.py


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


示例6: test_sorting_creator

 def test_sorting_creator(self):
     """Sorting threads by creator."""
     thread(creator=user(username='aaa', save=True), save=True)
     thread(creator=user(username='bbb', save=True), save=True)
     threads = sort_threads(Thread.objects, 3, 1)
     self.assert_(threads[0].creator.username >=
                  threads[1].creator.username)
开发者ID:Apokalyptica79,项目名称:kitsune,代码行数:7,代码来源:test_posts.py


示例7: test_active_contributors

    def test_active_contributors(self):
        """Test active contributors API call."""
        # 2 en-US revisions by 2 contributors:
        r1 = revision(creator=user(save=True), save=True)
        r2 = revision(creator=user(save=True), save=True)
        # A translation with 2 contributors (translator + reviewer):
        d = document(parent=r1.document, locale='es', save=True)
        revision(document=d, reviewed=datetime.now(),
                 reviewer=r1.creator, creator=r2.creator, save=True)
        # 1 active support forum contributor:
        # A user with 10 answers
        u1 = user(save=True)
        for x in range(10):
            answer(save=True, creator=u1)
        # A user with 9 answers
        u2 = user(save=True)
        for x in range(9):
            answer(save=True, creator=u2)
        # A user with 1 answer
        u3 = user(save=True)
        answer(save=True, creator=u3)

        # An AoA reply (1 contributor):
        reply(save=True)

        r = self._get_api_result('kpi_active_contributors')
        eq_(r['objects'][0]['en_us'], 2)
        eq_(r['objects'][0]['non_en_us'], 2)
        eq_(r['objects'][0]['support_forum'], 1)
        eq_(r['objects'][0]['aoa'], 1)
开发者ID:Curlified,项目名称:kitsune,代码行数:30,代码来源:test_api.py


示例8: test_watch_both_then_new_post

    def test_watch_both_then_new_post(self, get_current):
        """Watching both forum and thread.

        Replying to a thread should send ONE email."""
        get_current.return_value.domain = 'testserver'

        t = thread(save=True)
        f = t.forum
        forum_post(thread=t, save=True)
        poster = user(save=True)
        watcher = user(save=True)

        self._toggle_watch_forum_as(f, watcher, turn_on=True)
        self._toggle_watch_thread_as(t, watcher, turn_on=True)
        self.client.login(username=poster.username, password='testpass')
        post(self.client, 'forums.reply', {'content': 'a post'},
             args=[f.slug, t.id])

        eq_(1, len(mail.outbox))
        p = Post.objects.all().order_by('-id')[0]
        attrs_eq(mail.outbox[0], to=[watcher.email],
                 subject='Re: {f} - {t}'.format(f=f, t=t))
        body = REPLY_EMAIL.format(
            username=poster.username,
            forum_slug=f.slug,
            thread_title=t.title,
            thread_id=t.id,
            post_id=p.id)
        starts_with(mail.outbox[0].body, body)
开发者ID:Apokalyptica79,项目名称:kitsune,代码行数:29,代码来源:test_notifications.py


示例9: setUp

    def setUp(self, switch_is_active):
        switch_is_active.return_value = True

        super(KarmaManagerTests, self).setUp()

        try:
            self.mgr = KarmaManager()
            redis_client('karma').flushdb()
        except RedisError:
            raise SkipTest

        self.user1 = user(save=True)
        self.user2 = user(save=True)
        self.user3 = user(save=True)

        today = date.today()

        # user1 actions (3 + 3 + 7):
        TestAction1(user=self.user1, day=today).save()
        TestAction1(user=self.user1, day=today).save()
        TestAction2(user=self.user1, day=today).save()

        # user2 actions (3 + 7 + 7):
        TestAction1(user=self.user2, day=today - timedelta(days=8)).save()
        TestAction2(user=self.user2, day=today - timedelta(days=32)).save()
        TestAction2(user=self.user2, day=today - timedelta(days=360)).save()

        # user3 actions (3 + 3 + 3 + 7):
        TestAction1(user=self.user3, day=today - timedelta(days=10)).save()
        TestAction1(user=self.user3, day=today - timedelta(days=40)).save()
        TestAction1(user=self.user3, day=today - timedelta(days=190)).save()
        TestAction2(user=self.user3, day=today - timedelta(days=3)).save()
开发者ID:Apokalyptica79,项目名称:kitsune,代码行数:32,代码来源:test_manager.py


示例10: setUp

 def setUp(self):
     super(AddRemoveContributorTests, self).setUp()
     self.user = user(save=True)
     self.contributor = user(save=True)
     add_permission(self.user, Document, 'change_document')
     self.client.login(username=self.user.username, password='testpass')
     self.revision = revision(save=True)
     self.document = self.revision.document
开发者ID:Uwanja,项目名称:kitsune,代码行数:8,代码来源:test_views.py


示例11: test_sorting_creator

 def test_sorting_creator(self):
     """Sorting threads by creator."""
     u1 = user(username='foo', save=True)
     u2 = user(username='bar', save=True)
     thread(creator=u1, save=True)
     thread(creator=u2, save=True)
     threads = sort_threads(Thread.objects, 3, 1)
     self.assertEqual(threads[0].creator.username, u1.username)
     self.assertEqual(threads[1].creator.username, u2.username)
开发者ID:DWDRAEGER,项目名称:kitsune,代码行数:9,代码来源:__init__.py


示例12: setUp

    def setUp(self):
        # create active and inactive users
        self.active_user = user(save=True,
                                username='activeuser',
                                is_active=True)

        self.inactive_user = user(save=True,
                                  username='inactiveuser',
                                  is_active=False)
开发者ID:DWDRAEGER,项目名称:kitsune,代码行数:9,代码来源:test_forms.py


示例13: setUp

 def setUp(self):
     super(ThreadPermissionsTests, self).setUp()
     self.doc = document(save=True)
     self.u = user(save=True)
     self.thread = thread(document=self.doc, creator=self.u, save=True)
     self.post = self.thread.new_post(creator=self.thread.creator,
                                      content='foo')
     # Login for testing 403s
     u2 = user(save=True)
     self.client.login(username=u2.username, password='testpass')
开发者ID:DWDRAEGER,项目名称:kitsune,代码行数:10,代码来源:test_views.py


示例14: test_two_approved_revision

 def test_two_approved_revision(self):
     u1 = user(save=True)
     r1 = revision(save=True, is_approved=True, creator=u1)
     d = r1.document
     u2 = user(save=True)
     revision(save=True, is_approved=True, creator=u2, document=d)
     d.contributors.clear()
     _init_contributors()
     assert u1 in d.contributors.all()
     assert u2 in d.contributors.all()
开发者ID:jledbetter,项目名称:kitsune,代码行数:10,代码来源:test_commands.py


示例15: setUp

    def setUp(self):
        super(FlaggedQueueTestCase, self).setUp()
        q = question(creator=user(save=True), save=True)
        self.answer = answer(question=q,
                             creator=user(save=True),
                             save=True)

        self.flagger = user(save=True)
        u = user(save=True)
        add_permission(u, FlaggedObject, 'can_moderate')

        self.client.login(username=u.username, password='testpass')
开发者ID:Apokalyptica79,项目名称:kitsune,代码行数:12,代码来源:test_templates.py


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


示例17: test_watch_other_thread_then_reply

    def test_watch_other_thread_then_reply(self):
        """Watching a different thread than the one we're replying to shouldn't
        notify."""
        u_b = user(username='berkerpeksag', save=True)
        _t = thread(save=True)
        self._toggle_watch_thread_as(u_b.username, _t, turn_on=True)
        u = user(save=True)
        t2 = thread(save=True)
        self.client.login(username=u.username, password='testpass')
        post(self.client, 'wiki.discuss.reply', {'content': 'a post'},
             args=[t2.document.slug, t2.id])

        assert not mail.outbox
开发者ID:DWDRAEGER,项目名称:kitsune,代码行数:13,代码来源:test_notifications.py


示例18: test_watch_other_thread_then_reply

    def test_watch_other_thread_then_reply(self):
        """Watching a different thread than the one we're replying to shouldn't
        notify."""
        t1 = thread(save=True)
        t2 = thread(save=True)
        poster = user(save=True)
        watcher = user(save=True)

        self._toggle_watch_thread_as(t1, watcher, turn_on=True)
        self.client.login(username=poster.username, password='testpass')
        post(self.client, 'forums.reply', {'content': 'a post'},
             args=[t2.forum.slug, t2.id])

        assert not mail.outbox
开发者ID:Apokalyptica79,项目名称:kitsune,代码行数:14,代码来源:test_notifications.py


示例19: test_flag_kbforum_post

 def test_flag_kbforum_post(self):
     u = user(save=True)
     t = thread(save=True)
     p = t.new_post(creator=u, content='foo')
     f = FlaggedObject(content_object=p, reason='spam', creator_id=u.id)
     f.save()
     # Make sure flagit queue page works
     u2 = user(save=True)
     add_permission(u2, FlaggedObject, 'can_moderate')
     self.client.login(username=u2.username, password='testpass')
     response = get(self.client, 'flagit.queue')
     eq_(200, response.status_code)
     doc = pq(response.content)
     eq_(1, len(doc('#flagged-queue li')))
开发者ID:DWDRAEGER,项目名称:kitsune,代码行数:14,代码来源:test_templates.py


示例20: test_based_on_approved

 def test_based_on_approved(self):
     u1 = user()
     u1.save()
     r1 = revision(is_approved=False, creator=u1, is_ready_for_localization=False, save=True)
     u2 = user()
     u2.save()
     r2 = revision(
         document=r1.document, based_on=r1, is_approved=False, creator=u2, is_ready_for_localization=False, save=True
     )
     eq_(0, len(mail.outbox))
     self._review_revision(r=r2)
     eq_(3, len(mail.outbox))
     assert "has a new approved revision" in mail.outbox[0].subject
     assert "Your revision has been approved" in mail.outbox[1].subject
     assert "A revision you contributed to has" in mail.outbox[2].subject
开发者ID:erikrose,项目名称:kitsune,代码行数:15,代码来源:test_notifications.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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