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


Python EternalProcess.map_reduce_tweets_after_disconnect方法代码示例

本文整理汇总了Python中Twitter_Utils.EternalProcess.EternalProcess.map_reduce_tweets_after_disconnect方法的典型用法代码示例。如果您正苦于以下问题:Python EternalProcess.map_reduce_tweets_after_disconnect方法的具体用法?Python EternalProcess.map_reduce_tweets_after_disconnect怎么用?Python EternalProcess.map_reduce_tweets_after_disconnect使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Twitter_Utils.EternalProcess.EternalProcess的用法示例。


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

示例1: TestEternalProcess

# 需要导入模块: from Twitter_Utils.EternalProcess import EternalProcess [as 别名]
# 或者: from Twitter_Utils.EternalProcess.EternalProcess import map_reduce_tweets_after_disconnect [as 别名]

#.........这里部分代码省略.........
        eternal_process = EternalProcess()
        now_plus_10 = now + datetime.timedelta(minutes=10)
        now_plus_10 = now_plus_10.strftime('%H:%M')
        self.assertEqual(now_plus_10, eternal_process.get_time_to_end_stream(10))

    def test_get_write_path_for_days_games(self):
        eternal_process = EternalProcess()
        wd = os.getcwd()
        pos = wd.find("BigDataMonsters")
        if pos > 0:  # pragma: no cover
            path = wd[0:pos+15]
        else:
            path = wd
        base = path + '/Twitter_Utils/data/daily-logs/'
        end = datetime.datetime.now().strftime('%Y-%m-%d') + '.json'
        self.assertEqual(base + end, eternal_process.get_write_path_for_days_games())

    def test_is_time_to_get_game_data_for_day(self):
        eternal_process = EternalProcess()
        eternal_process.time_to_check_games_for_the_day = datetime.datetime.now().strftime('%H:%M')
        self.assertEqual(True, eternal_process.is_time_to_get_game_data_for_day())
        eternal_process.time_to_check_games_for_the_day = '04:14'
        self.assertEqual(False, eternal_process.is_time_to_get_game_data_for_day())

    def test_sleep_for(self):
        eternal_process = EternalProcess()
        time_now = datetime.datetime.now()
        eternal_process.sleep_for(1, time.time())
        time_now_plus_1 = datetime.datetime.now().strftime('%H:%M:%S')
        time_now += datetime.timedelta(seconds=1)
        time_now = time_now.strftime('%H:%M:%S')
        self.assertEqual(time_now, time_now_plus_1)

    def test_map_reduce_tweets_after_disconnect(self):
        self.eternalProcess.game_name_list.append('123')
        path = self.eternalProcess.get_game_name_base_file_path(0)
        self.assertIsNotNone(self.eternalProcess.map_reduce_tweets_after_disconnect(path, 0))

    def test_get_game_name_base_file_path(self):
        self.eternalProcess.game_name_list.append('2016-03-05-Pacers-vs-Wizards')
        self.assertEqual(os.getcwd() + '/Twitter_Utils/data/tweets/2016-03-05-Pacers-vs-Wizards/'
                                       '2016-03-05-Pacers-vs-Wizards.txt',
                         self.eternalProcess.get_game_name_base_file_path(0))

    def test_delete_stream_end_time_game_name_from_lists(self):
        eternal_process = EternalProcess()
        eternal_process.stream_list.append('Stream Test')
        eternal_process.end_times_list.append('End Time Test')
        eternal_process.game_name_list.append('Game Test')
        self.assertIs(len(eternal_process.stream_list), 1)
        self.assertIs(len(eternal_process.end_times_list), 1)
        self.assertIs(len(eternal_process.game_name_list), 1)
        eternal_process.delete_stream_end_time_game_name_from_lists(0)
        self.assertIs(len(eternal_process.stream_list), 0)
        self.assertIs(len(eternal_process.end_times_list), 0)
        self.assertIs(len(eternal_process.game_name_list), 0)

    def test_get_game_name_directory(self):
        eternal_process = EternalProcess()
        eternal_process.game_name_list.append('Test_game')
        expected = 'Twitter_Utils/data/tweets/Test_game/'
        self.assertEqual(expected, eternal_process.get_game_name_directory(0))

    def test_remove_first_line_from_file(self):
        eternal_process = EternalProcess()
        path = os.getcwd() + '/Twitter_Utils/data/tweets/base_tweets_for_tests/base_tweets_for_tests.txt'
开发者ID:mguida22,项目名称:SportsCanary,代码行数:70,代码来源:test_EternalProcess.py


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