def __init__(self, api): self.api = api self.factory = TimelineFactory(api) self.sessions_conf = RawConfigParser() self.sessions = { DEFAULT_SESSION: { VISIBLE: HOME_TIMELINE, BUFFERS: ', '.join([MENTIONS_TIMELINE, FAVORITES_TIMELINE, MESSAGES_TIMELINE, OWN_TWEETS_TIMELINE]) } } if not path.isfile(SESSIONS_FILE): # create the sessions file logging.info(_('Sessions file created')) self.init_sessions_file()
def setUp(self): self.factory = TimelineFactory(mock_api)
class TimelineFactoryTest(unittest.TestCase): def setUp(self): self.factory = TimelineFactory(mock_api) def valid_name(self, timeline_name): """Test that `timeline_name` is a valid timeline name.""" self.assertTrue(self.factory.valid_timeline_name(timeline_name)) def test_default_names_are_valid_timeline_names(self): self.valid_name('home') self.valid_name('mentions') self.valid_name('favorites') self.valid_name('messages') self.valid_name('own_tweets') def test_search_names_are_valid_timeline_name(self): self.valid_name('search:turses') self.valid_name('search:I love ramen!') self.valid_name('search:#Python is awesome') def test_user_names_are_valid_timeline_name(self): self.valid_name('user:dialelo') self.valid_name('user:PepeGuer') def test_retweets_of_me_is_valid_timeline_name(self): self.valid_name('retweets_of_me') def created_timeline_verifies(self, name, prop): """ Test that the timeline created from `name` verifies the `prop` property. """ timeline = self.factory(name) self.assertTrue(prop(timeline)) # TODO: remove hardcoded timeline names def test_timeline_factory_home(self): self.created_timeline_verifies('home', is_home_timeline) def test_timeline_factory_mentions(self): self.created_timeline_verifies('mentions', is_mentions_timeline) def test_timeline_factory_favorites(self): self.created_timeline_verifies('favorites', is_favorites_timeline) def test_timeline_factory_messages(self): self.created_timeline_verifies('messages', is_messages_timeline) def test_timeline_factory_own_tweets(self): self.created_timeline_verifies('own_tweets', is_own_timeline) def test_timeline_factory_search(self): self.created_timeline_verifies('search:turses', is_search_timeline) def test_timeline_factory_search_query(self): query = 'Programming is fun' timeline = self.factory(':'.join(['search', query])) self.assertEqual(timeline._args, [query]) def test_timeline_factory_retweets_of_me(self): self.created_timeline_verifies('retweets_of_me', is_retweets_of_me_timeline) 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) def test_dm_thread(self): message = create_direct_message() dm_thread_timeline = self.factory.thread(message) self.assertEqual( dm_thread_timeline.update_function.__name__, 'get_message_thread', ) self.assertEqual(dm_thread_timeline._args[0], message)
class TimelineFactoryTest(unittest.TestCase): def setUp(self): self.factory = TimelineFactory(mock_api) def valid_name(self, timeline_name): """Test that `timeline_name` is a valid timeline name.""" self.assertTrue(self.factory.valid_timeline_name(timeline_name)) def test_default_names_are_valid_timeline_names(self): self.valid_name('home') self.valid_name('mentions') self.valid_name('favorites') self.valid_name('messages') self.valid_name('own_tweets') def test_search_names_are_valid_timeline_name(self): self.valid_name('search:turses') self.valid_name('search:I love ramen!') self.valid_name('search:#Python is awesome') def test_user_names_are_valid_timeline_name(self): self.valid_name('user:dialelo') self.valid_name('user:PepeGuer') def test_retweets_of_me_is_valid_timeline_name(self): self.valid_name('retweets_of_me') def created_timeline_verifies(self, name, prop): """ Test that the timeline created from `name` verifies the `prop` property. """ timeline = self.factory(name) self.assertTrue(prop(timeline)) # TODO: remove hardcoded timeline names def test_timeline_factory_home(self): self.created_timeline_verifies('home', is_home_timeline) def test_timeline_factory_mentions(self): self.created_timeline_verifies('mentions', is_mentions_timeline) def test_timeline_factory_favorites(self): self.created_timeline_verifies('favorites', is_favorites_timeline) def test_timeline_factory_messages(self): self.created_timeline_verifies('messages', is_messages_timeline) def test_timeline_factory_own_tweets(self): self.created_timeline_verifies('own_tweets', is_own_timeline) def test_timeline_factory_search(self): self.created_timeline_verifies('search:turses', is_search_timeline) def test_timeline_factory_search_query(self): query = 'Programming is fun' timeline = self.factory(':'.join(['search', query])) self.assertEqual(timeline._args, [query]) def test_timeline_factory_retweets_of_me(self): self.created_timeline_verifies('retweets_of_me', is_retweets_of_me_timeline) 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) def test_dm_thread(self): message = create_direct_message() dm_thread_timeline = self.factory.thread(message) self.assertEqual(dm_thread_timeline.update_function.__name__, 'get_message_thread',) self.assertEqual(dm_thread_timeline._args[0], message)