当前位置: 首页>>代码示例>>Python>>正文


Python tests.user函数代码示例

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


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


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