def main(): """ Launch ``turses``. """ set_title(__name__) set_encoding('utf8') args = read_arguments() # check if stdout has to be restored after program exit if any([ args.debug, args.offline, getattr(args, 'help', False), getattr(args, 'version', False) ]): # we are going to print information to stdout save_and_restore_stdout = False else: save_and_restore_stdout = True if save_and_restore_stdout: save_stdout() # parse arguments and load configuration configuration.parse_args(args) configuration.load() # start logger logging.basicConfig(filename=LOG_FILE, level=configuration.logging_level) # create view curses_interface = CursesInterface() # create model timeline_list = TimelineList() # create API api = create_async_api(MockApi if args.offline else TweepyApi) # create controller turses = Turses( ui=curses_interface, api=api, timelines=timeline_list, ) try: turses.start() except Exception: # A unexpected exception occurred, open the debugger in debug mode if args.debug or args.offline: import pdb pdb.post_mortem() finally: if save_and_restore_stdout: restore_stdout() restore_title() exit(0)
def main(): """ Launch ``turses``. """ set_title(__name__) set_encoding('utf8') args = parse_arguments() # check if stdout has to be restored after program exit if any([args.debug, args.offline, getattr(args, 'help', False), getattr(args, 'version', False)]): # we are going to print information to stdout save_and_restore_stdout = False else: save_and_restore_stdout = True if save_and_restore_stdout: save_stdout() # load configuration configuration = Configuration(args) configuration.load() # start logger logging.basicConfig(filename=LOG_FILE, level=configuration.logging_level) # create view curses_interface = CursesInterface(configuration) # select API backend if args.offline: api_backend = MockApi else: api_backend = TweepyApi # create controller turses = Turses(configuration=configuration, ui=curses_interface, api_backend=api_backend) try: turses.start() except KeyboardInterrupt: pass except: # open the debugger if args.debug or args.offline: import pdb pdb.post_mortem() finally: if save_and_restore_stdout: restore_stdout() restore_title() exit(0)
def main(): """ Launch ``turses``. """ set_title(__name__) set_encoding('utf8') args = read_arguments() # check if stdout has to be restored after program exit if any([args.debug, args.offline, getattr(args, 'help', False), getattr(args, 'version', False)]): # we are going to print information to stdout save_and_restore_stdout = False else: save_and_restore_stdout = True if save_and_restore_stdout: save_stdout() # parse arguments and load configuration configuration.parse_args(args) configuration.load() # start logger logging.basicConfig(filename=LOG_FILE, level=configuration.logging_level) # create view curses_interface = CursesInterface() # create model timeline_list = TimelineList() # create API api = create_async_api(MockApi if args.offline else TweepyApi) # create controller turses = Turses(ui=curses_interface, api=api, timelines=timeline_list,) try: turses.start() except: # A unexpected exception occurred, open the debugger in debug mode if args.debug or args.offline: import pdb pdb.post_mortem() finally: if save_and_restore_stdout: restore_stdout() restore_title() exit(0)
def main(): """ Launch ``turses``. """ set_title(__name__) set_encoding('utf8') args = read_arguments() # check if stdout has to be restored after program exit if any([ args.debug, args.offline, getattr(args, 'help', False), getattr(args, 'version', False) ]): # we are going to print information to stdout save_and_restore_stdout = False else: save_and_restore_stdout = True if save_and_restore_stdout: save_stdout() # parse arguments and load configuration configuration.parse_args(args) configuration.load() # start logger logging.basicConfig(filename=LOG_FILE, level=configuration.logging_level) # create view curses_interface = CursesInterface() # select API backend if args.offline: api_backend = MockApi else: api_backend = TweepyApi # create controller turses = Turses(ui=curses_interface, api_backend=api_backend) try: turses.start() except KeyboardInterrupt: pass except: # open the debugger if args.debug or args.offline: import pdb pdb.post_mortem() finally: if save_and_restore_stdout: restore_stdout() restore_title() exit(0)
def setUp(self): self.timelines = TimelineList() self.controller = Controller(ui=Mock(), api=MockApi("foo", "bar"), timelines=self.timelines)
class ControllerTest(unittest.TestCase): def setUp(self): self.timelines = TimelineList() self.controller = Controller(ui=Mock(), api=MockApi("foo", "bar"), timelines=self.timelines) def test_append_home_timeline(self): self.controller.append_home_timeline() appended_timeline = self.timelines[-1] self.assertTrue(is_home_timeline(appended_timeline)) def test_append_user_timeline(self): user = "******" self.controller.append_user_timeline(user) appended_timeline = self.timelines[-1] self.assertTrue(is_user_timeline(appended_timeline)) self.assertEqual(appended_timeline._kwargs, {"screen_name": user}) def test_own_tweets_timeline(self): self.controller.append_own_tweets_timeline() appended_timeline = self.timelines[-1] self.assertTrue(is_own_timeline(appended_timeline)) def test_mentions_timeline(self): self.controller.append_mentions_timeline() appended_timeline = self.timelines[-1] self.assertTrue(is_mentions_timeline(appended_timeline)) def test_direct_messages_timeline(self): self.controller.append_direct_messages_timeline() appended_timeline = self.timelines[-1] self.assertTrue(is_messages_timeline(appended_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))
def setUp(self): self.timelines = TimelineList() self.controller = Controller(ui=Mock(), api=MockApi('foo', 'bar'), timelines=self.timelines)
class ControllerTest(unittest.TestCase): def setUp(self): self.timelines = TimelineList() self.controller = Controller(ui=Mock(), api=MockApi('foo', 'bar'), timelines=self.timelines) def test_append_home_timeline(self): self.controller.append_home_timeline() appended_timeline = self.timelines[-1] self.assertTrue(is_home_timeline(appended_timeline)) def test_append_user_timeline(self): user = '******' self.controller.append_user_timeline(user) appended_timeline = self.timelines[-1] self.assertTrue(is_user_timeline(appended_timeline)) self.assertEqual(appended_timeline._kwargs, {'screen_name': user}) def test_own_tweets_timeline(self): self.controller.append_own_tweets_timeline() appended_timeline = self.timelines[-1] self.assertTrue(is_own_timeline(appended_timeline)) def test_mentions_timeline(self): self.controller.append_mentions_timeline() appended_timeline = self.timelines[-1] self.assertTrue(is_mentions_timeline(appended_timeline)) def test_direct_messages_timeline(self): self.controller.append_direct_messages_timeline() appended_timeline = self.timelines[-1] self.assertTrue(is_messages_timeline(appended_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))