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

Python tests.create_status函数代码示例

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

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



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

示例1: test_insert_different_statuses

    def test_insert_different_statuses(self):
        old_status = create_status(created_at=datetime(1988, 12, 19))
        new_status = create_status(id=2)

        self.timeline.add_statuses([old_status, new_status])

        self.assertEqual(len(self.timeline), 2)
开发者ID:battlemidget,项目名称:turses,代码行数:7,代码来源:test_models.py


示例2: test_map_attributes_to_retweet_with_hashtag

    def test_map_attributes_to_retweet_with_hashtag(self):
        original_author = 'dialelo'
        original_text = 'I <3 #Python'
        original_status = create_status(user=original_author,
                                        text=original_text)

        text = 'RT @%s: %s' % (original_author, original_text)
        entities = {
            u'user_mentions': [],
            u'hashtags': [
                {u'indices': [5, 11],
                 u'text': u'Python'},
            ],
            u'urls': [],
            }
        retweet = create_status(text=text,
                                entities=entities,
                                is_retweet=True,
                                retweeted_status=original_status)

        # retweet text gets parsed because sometimes is not complete
        expected_result = [u'I ', u'<3 ', ('hashtag', '#Python')]
        result = map_attributes(retweet,
                                hashtag='hashtag',
                                attag='attag',
                                url='url')

        self.assertEqual(result, expected_result)
开发者ID:diegorocha,项目名称:turses,代码行数:28,代码来源:test_ui.py


示例3: test_insert_different_statuses_individually

    def test_insert_different_statuses_individually(self):
        old_status = create_status(created_at=datetime(1988, 12, 19))
        new_status = create_status(id=2)

        # first
        self.timeline.add_status(old_status)
        self.assertEqual(len(self.timeline), 1)

        # second
        self.timeline.add_status(new_status)
        self.assertEqual(len(self.timeline), 2)
开发者ID:battlemidget,项目名称:turses,代码行数:11,代码来源:test_models.py


示例4: test_active_index_does_not_change_when_adding_various_statuses

    def test_active_index_does_not_change_when_adding_various_statuses(self):
        a_status = create_status(id=1)
        another_status = create_status(id=2)

        # first
        self.timeline.add_status(a_status)
        self.assertEqual(self.timeline.active_index, 0)

        # second
        self.timeline.add_status(another_status)
        self.assertEqual(self.timeline.active_index, 0)
开发者ID:battlemidget,项目名称:turses,代码行数:11,代码来源:test_models.py


示例5: test_clear

    def test_clear(self):
        old_created_at = datetime(1988, 12, 19)
        old_status = create_status(created_at=old_created_at)
        new_created_at = datetime.now()
        new_status = create_status(id=2,
                                   created_at=new_created_at)

        self.timeline.add_statuses([old_status, new_status])

        self.timeline.clear()

        self.assertEqual(len(self.timeline), 0)
开发者ID:battlemidget,项目名称:turses,代码行数:12,代码来源:test_models.py


示例6: test_authors_username_retweet

    def test_authors_username_retweet(self):
        user = 'turses'
        status = create_status(user=user)
        retweeter = 'bot'
        retweet = create_status(user=retweeter,
                                is_retweet=True,
                                retweeted_status=status,
                                author=user)

        author = retweet.authors_username

        self.assertEqual(user, author)
开发者ID:battlemidget,项目名称:turses,代码行数:12,代码来源:test_models.py


示例7: test_statuses_ordered_reversely_by_date

    def test_statuses_ordered_reversely_by_date(self):
        old_status = create_status(created_at=datetime(1988, 12, 19))
        new_status = create_status(id=2)

        # ordered
        self.timeline = Timeline(statuses=[new_status, old_status])
        self.assertEqual(self.timeline[0], new_status)
        self.assertEqual(self.timeline[1], old_status)

        # unordered
        self.timeline = Timeline(statuses=[old_status, new_status])
        self.assertEqual(self.timeline[0], new_status)
        self.assertEqual(self.timeline[1], old_status)
开发者ID:battlemidget,项目名称:turses,代码行数:13,代码来源:test_models.py


示例8: test_is_DM

    def test_is_DM(self):
        # status is NOT a DM
        status = create_status()
        self.failIf(is_DM(status))

        dm = create_direct_message()
        self.failUnless(is_DM(dm))
开发者ID:battlemidget,项目名称:turses,代码行数:7,代码来源:test_models.py


示例9: test_authors_username_tweet

    def test_authors_username_tweet(self):
        user = 'turses'
        status = create_status(user=user)

        author = status.authors_username

        self.assertEqual(user, author)
开发者ID:battlemidget,项目名称:turses,代码行数:7,代码来源:test_models.py


示例10: test_is_DM

    def test_is_DM(self):
        # status is NOT a DM
        status = create_status()
        self.assertFalse(is_DM(status))

        dm = create_direct_message()
        self.assertTrue(is_DM(dm))
开发者ID:fmartingr,项目名称:turses,代码行数:7,代码来源:test_models.py


示例11: test_unique_statuses_in_timeline

    def test_unique_statuses_in_timeline(self):
        status = create_status()

        self.timeline.add_status(status)
        self.timeline.add_status(status)

        self.assertEqual(len(self.timeline), 1)
开发者ID:battlemidget,项目名称:turses,代码行数:7,代码来源:test_models.py


示例12: test_thread

    def test_thread(self):
        status = create_status()

        thread_timeline = self.factory.thread(status)

        self.assertEqual(thread_timeline.update_function.__name__,
                         'get_thread',)
        self.assertEqual(thread_timeline._args[0], status)
开发者ID:fmartingr,项目名称:turses,代码行数:8,代码来源:test_api.py


示例13: test_unread_count

    def test_unread_count(self):
        self.assertEqual(self.timeline.unread_count, 0)

        # a status
        status = create_status(id=1)
        self.timeline.add_status(status)
        self.assertEqual(self.timeline.unread_count, 1)

        self.timeline.mark_all_as_read()
        self.assertEqual(self.timeline.unread_count, 0)

        # new statuses
        statuses = [create_status(id=id_num) for id_num in xrange(2, 10)]
        self.timeline.add_statuses(statuses)
        self.assertEqual(self.timeline.unread_count, len(statuses))

        self.timeline.mark_all_as_read()
        self.assertEqual(self.timeline.unread_count, 0)
开发者ID:battlemidget,项目名称:turses,代码行数:18,代码来源:test_models.py


示例14: test_dm_recipients_username_tweet

    def test_dm_recipients_username_tweet(self):
        # authenticating user
        user = 'turses'

        # given a status in which the author is the authenticated author
        # must return `None`
        status = create_status(user=user)
        recipient_own_tweet = status.dm_recipients_username(user)
        self.failIf(recipient_own_tweet)
开发者ID:battlemidget,项目名称:turses,代码行数:9,代码来源:test_models.py


示例15: test_thread_timeline

    def test_thread_timeline(self):
        active_timeline = self.controller.timelines.active
        active_timeline.add_status(create_status())
        # make sure that there is at least one status in the active timeline
        self.assertTrue(active_timeline.active)

        self.controller.append_thread_timeline()

        appended_timeline = self.timelines[-1]
        self.assertTrue(is_thread_timeline(appended_timeline))
开发者ID:noisufnoc,项目名称:turses,代码行数:10,代码来源:test_core.py


示例16: test_hashtags

    def test_hashtags(self):
        user = 'turses'
        hashtags = ('#turses', '#arch_linux', '#I<3Python')

        expected_output = list(hashtags)

        text = "%s %s %s" % hashtags
        status = create_status(user=user,
                               text=text)

        expected = set(expected_output)
        mentioned_hashtags = status.hashtags
        self.assertEqual(expected, set(mentioned_hashtags))
开发者ID:battlemidget,项目名称:turses,代码行数:13,代码来源:test_models.py


示例17: test_mentioned_usernames

    def test_mentioned_usernames(self):
        user = 'turses'
        mentioned = ('dialelo', 'mental_floss', '4n_4Wfu1_US3RN4M3')

        expected_output = list(mentioned)

        text = "@%s, @%s and @%s" % mentioned
        status = create_status(user=user,
                               text=text)

        expected = set(expected_output)
        mentioned_usernames = status.mentioned_usernames
        self.assertEqual(expected, set(mentioned_usernames))
开发者ID:battlemidget,项目名称:turses,代码行数:13,代码来源:test_models.py


示例18: test_mentioned_for_reply

    def test_mentioned_for_reply(self):
        user = 'turses'
        mentioned = ('dialelo', 'mental_floss', '4n_4Wfu1_US3RN4M3')

        expected_output = list(mentioned)
        expected_output.append(user)
        expected_output = map(prepend_at, expected_output)

        text = "@%s, @%s and @%s" % mentioned
        status = create_status(user=user,
                               text=text)

        expected = set(filter(prepend_at, expected_output))
        mentioned_for_reply = status.mentioned_for_reply
        self.assertEqual(expected, set(mentioned_for_reply))
开发者ID:battlemidget,项目名称:turses,代码行数:15,代码来源:test_models.py


示例19: test_timeline

    def test_timeline(self):
        timeline = tests.create_timeline()

        self.assertTrue(isinstance(timeline, Timeline))
        self.assertEqual(0, len(timeline.statuses))

        status = None
        with self.assertRaises(Exception):
            timeline.add(status)

        status2 = tests.create_another_status()
        self.assertRaises(ValueError, timeline.remove(status2))

        status = tests.create_status()
        timeline.add(status)
        self.assertEqual(1, len(timeline.statuses))

        timeline.remove(status)
        self.assertEqual(0, len(timeline.statuses))
开发者ID:ervitis,项目名称:twipy,代码行数:19,代码来源:test_models.py


示例20: test_map_attributes_mention

    def test_map_attributes_mention(self):
        text = '@pypi is down!'

        entities = {
            u'user_mentions': [
                {u'id': 60840400,
                 u'indices': [0, 5],
                 u'id_str': u'60840400',
                 u'screen_name': u'pypi',
                 u'name': u'PYthon Package Index'},
            ],
            u'hashtags': [],
            u'urls': [],
            }
        tweet = create_status(text=text,
                              entities=entities,)

        expected_result = [('attag', u'@pypi'), u' is down!']
        result = tweet.map_attributes(hashtag='hashtag',
                                      attag='attag',
                                      url='url')

        self.assertEqual(result, expected_result)
开发者ID:ivanov,项目名称:turses,代码行数:23,代码来源:test_models.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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