本文整理汇总了Python中Twitter_Utils.EternalProcess.EternalProcess类的典型用法代码示例。如果您正苦于以下问题:Python EternalProcess类的具体用法?Python EternalProcess怎么用?Python EternalProcess使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了EternalProcess类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_update_is_streamed_json
def test_update_is_streamed_json(self):
eternal_process = EternalProcess()
game = dict(_id='f334b7d4-a1fb-4ed6-ad85-ba75f71f0b1f', being_streamed=False)
sport = 'nba'
self.assertEqual(True, eternal_process.update_is_streamed_json(game, sport))
game = dict(_id='f334b7d4-a1fb-4ed6-ad85-ba75f71f0b1f', being_streamed=True)
self.assertEqual(False, eternal_process.update_is_streamed_json(game, sport))
示例2: test_update_is_streamed_json_mlb
def test_update_is_streamed_json_mlb(self):
eternal_process = EternalProcess()
game = dict(_id='80a57e73-cf37-47c7-869d-e5fe43983fb3', being_streamed=False)
sport = 'mlb'
self.assertEqual(True, eternal_process.update_is_streamed_json(game, sport))
game = dict(_id='80a57e73-cf37-47c7-869d-e5fe43983fb3', being_streamed=True)
self.assertEqual(False, eternal_process.update_is_streamed_json(game, sport))
示例3: test_update_is_streamed_json_nhl
def test_update_is_streamed_json_nhl(self):
eternal_process = EternalProcess()
game = dict(_id='91775c7f-fecf-49d1-91ce-400a9975dd8f', being_streamed=False)
sport = 'nhl'
self.assertEqual(True, eternal_process.update_is_streamed_json(game, sport))
game = dict(_id='91775c7f-fecf-49d1-91ce-400a9975dd8f', being_streamed=True)
self.assertEqual(False, eternal_process.update_is_streamed_json(game, sport))
示例4: test_sleep_for
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)
示例5: test_get_aws_mongo_db
def test_get_aws_mongo_db(self):
eternal_process = EternalProcess()
uri = 'mongodb://' + CommonUtils.get_environ_variable('AWS_MONGO_USER') + ':' \
+ CommonUtils.get_environ_variable('AWS_MONGO_PASS') + '@' \
+ CommonUtils.get_environ_variable('AWS_ADDRESS')
client = MongoClient(uri)
expected = client.eventsDB
self.assertEqual(expected, eternal_process.get_aws_mongo_db())
示例6: test_get_team_name_base_file_path
def test_get_team_name_base_file_path(self):
eternal_process = EternalProcess()
# ExpectedNone
self.assertIsNone(eternal_process.get_team_name_base_file_path(0))
eternal_process.game_name_list.append('Cavaliers-vs-Bronx')
expected = os.getcwd() + '/Twitter_Utils/data/tweets/Cavaliers-vs-Bronx/Cavaliers-vs-Bronx.txt'
self.assertEqual(expected, eternal_process.get_game_name_base_file_path(0))
示例7: test_iterate_through_daily_games_and_start_stream
def test_iterate_through_daily_games_and_start_stream(self):
eternal_process = EternalProcess()
start_time = datetime.datetime.now() + datetime.timedelta(minutes=180)
data = [{'start_time': str(start_time), 'being_streamed': False, '_id': 'fak31D',
'title': 'Cavaliers vs Mavericks',
'home_team_id': 'a9abb922-3a47-4d37-9250-2e5224a2b58a',
'away_team_id': '35ded680-b7b1-4cd9-a223-7bc4ab0b77ed'}]
current_time = eternal_process.get_time_as_hour_minute()
eternal_process.iterate_through_daily_games_and_start_stream(data, current_time, "nba")
self.assertEqual(1, len(eternal_process.game_name_list))
self.assertIs(True, eternal_process.end_stream_and_free_api(0))
示例8: test_get_write_path_for_days_games
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())
示例9: test_get_index_and_clear_api_key_at_index
def test_get_index_and_clear_api_key_at_index(self):
eternal_process = EternalProcess()
twitter_key_handler = TwitterAPIKeyHandler()
test_stream = 'test stream', 0
eternal_process.stream_list.append(test_stream)
self.assertEqual(False, eternal_process.get_index_and_clear_api_key_at_index(0))
with open(twitter_key_handler.key_check_write_path) as f:
data = json.load(f)
twitter_key_handler.update_json_file(data, 0)
test_stream = 'test stream', 0
eternal_process.stream_list.append(test_stream)
self.assertEqual(True, eternal_process.get_index_and_clear_api_key_at_index(0))
示例10: test_delete_stream_end_time_game_name_from_lists
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)
示例11: test_remove_last_line_from_file
def test_remove_last_line_from_file(self):
eternal_process = EternalProcess()
path = os.getcwd() + '/Twitter_Utils/data/tweets/base_tweets_for_tests/base_tweets_for_tests.txt'
count_1 = 0
with open(path, 'r') as reader:
for _ in reader:
count_1 += 1
reader.close()
self.assertIs(True, eternal_process.remove_last_line_from_file(path))
count_2 = 0
with open(path, 'r') as reader:
for _ in reader:
count_2 += 1
reader.close()
self.assertEqual(count_1-1, count_2)
示例12: setUp
def setUp(self):
self.eternalProcess = EternalProcess()
self.stream_list = []
self.end_times_list = []
self.time_to_check_games_for_the_day = '09:30'
self.data_gatherer = DataGatherer()
self.time_now = datetime.datetime.now()
path = self.eternalProcess.base_path + self.time_now.strftime('%Y-%m-%d') + '.json'
fo = open(path, 'w+')
fo.write('[{"uuid": "4b2fb0bc-864c-4ede-be61-59ed14e1da50", "title": "Spurs vs Clippers",'
'"start_time": "2016-02-18T17:18:00-08:00", "being_streamed": true, "home_team_id":'
'"5bf2300f-777b-4caa-9ef3-3fda11f17ad1", "away_team_id": "ed803cc0-8e6e-4798-b5aa-9eecbc977801",'
'"slug": "nba-2015-2016-sa-lac-2016-02-18-1930"}]')
fo.close()
# register remove function
self.addCleanup(os.remove, path)
dir_path = os.getcwd() + '/Twitter_Utils/data/tweets/base_tweets_for_tests'
if not os.path.exists(dir_path):
os.makedirs(dir_path)
self.addCleanup(os.rmdir, dir_path)
self.path_2 = os.getcwd() + '/Twitter_Utils/data/tweets/base_tweets_for_tests/base_tweets_for_tests.txt'
fo = open(self.path_2, 'w+')
fo.write('test tweet 1\ntest tweet 1\ntest tweet 1\ntest tweet 1\ntest tweet 2\ntest tweet 2\ntest tweet 2\n')
fo.close()
self.addCleanup(os.remove, self.path_2)
示例13: TestEternalProcess
class TestEternalProcess(unittest.TestCase):
def test___init__(self):
assert True
def setUp(self):
self.eternalProcess = EternalProcess()
self.stream_list = []
self.end_times_list = []
self.time_to_check_games_for_the_day = '09:30'
self.data_gatherer = DataGatherer()
def test_check_if_stream_should_end(self):
# Shouldn't end if there is no stream
self.assertEqual(False, self.eternalProcess.check_if_stream_should_end())
# Should end if there is a stream
self.eternalProcess.end_times_list.append(datetime.datetime.now().strftime('%H:%M'))
stream = self.data_gatherer.get_tweet_stream('ok', '123', '123')
self.eternalProcess.stream_list.append(stream)
self.assertEqual(True, self.eternalProcess.check_if_stream_should_end())
def test_get_time_to_end_stream(self):
eternal_process = EternalProcess()
now = datetime.datetime.now()
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()
base = os.getcwd() + '/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_write_days_games_data(self):
assert True
def test_sleep_for(self):
assert True
示例14: test_is_time_to_update_scores_for_day
def test_is_time_to_update_scores_for_day(self): # pragma: no cover
eternal_process = EternalProcess()
if datetime.datetime.now().strftime('%H:%M') == '02:00':
self.assertEqual(True, eternal_process.is_time_to_update_scores_for_day())
else:
self.assertEqual(False, eternal_process.is_time_to_update_scores_for_day())
示例15: EternalProcess
from Twitter_Utils.EternalProcess import EternalProcess # pragma: no cover
from urllib3.contrib import pyopenssl # pragma: no cover
from Eternal_Utils import SetupLogging # pragma: no cover
pyopenssl.inject_into_urllib3() # pragma: no cover
if __name__ == "__main__": # pragma: no cover
SetupLogging.setup_logging()
process = EternalProcess()
process.start_process()