Exemple #1
0
    def test_window(self):
        """
        The window method of the UI class wil be tested to determine if the
        window was rendered on top of the window representing the whole screen.
        """
        try:
            ui = UI()

            # Window object: The window that will be rendered on the terminal.
            window = ui.window(height=10, width=10, x=1, y=1)
            ui.border(window)

        except(curses.error):
            ui.cleanup()
            traceback.print_exc()

            # TestCase object: Interface with the TestCase class to control the
            #                  outcome and behavior of the test.
            test = unittest.TestCase()
            test.fail()

        except(KeyboardInterrupt):
            ui.cleanup()

        else:
            ui.cleanup()
Exemple #2
0
    def test_init(self):
        """
        The __init__ method of the UI class will be tested to determine if the
        window representing the whole screen was rendered correctly on the
        terminal.
        """
        try:
            
            # UI object: The user interface of the nuncium application.
            ui = UI()
            ui.border()

        except KeyboardInterrupt:
            ui.cleanup()

        else:
            ui.cleanup()
Exemple #3
0
    def test_fetch_news(self):
        """
        The fetch_news method of the news module will be tested to determine if
        the news content was fetched correctly from the specified source.
        """
        try:
            warnings.simplefilter("ignore", ResourceWarning)
            warnings.simplefilter("ignore", DeprecationWarning)

            # UI object: The user interface of the nuncium application.
            ui = UI()
            window = ui.window(curses.LINES, curses.COLS)
            ui.border(window)

            # News object: The news aggregator of the nuncium application.
            news = News()
            news.fetch_news(ui, window)

        except(KeyboardInterrupt, curses.error):
            ui.cleanup()

        else:
            ui.cleanup()
Exemple #4
0
    def test_display_menu(self):
        """
        The display_menu method of the UI class will be tested to determine if the
        menu was displayed correctly on the menu window.
        """
        try:
            ui = UI()

            # Integer: The height will consist of the entire screen and the
            #          width will consist of 1/5 of the screen's width.
            height = curses.LINES
            width = int(curses.COLS / 5)

            # List[string]: The news categories to display on the menu.
            category = ['Top Stories', 'Politics', 'Business', 'Finance',
                        'World News', 'Celebrity', 'Entertainment', 'Sports',
                        'Health', 'Science', 'Technology']

            # Window object: The window that will render the menu interface.
            menu_window = ui.window(height, width)

            # Display each submenu of the categories by simulating the user
            # selecting each category on the menu.
            for entry in category:
                ui.display_menu(menu_window, entry)
                ui.border(menu_window)
                menu_window.erase()

        except(curses.error):
            ui.cleanup()
            traceback.print_exc()

            test = unittest.Testcase()
            test.fail()

        except(KeyboardInterrupt):
            ui.cleanup()

        else:
            ui.cleanup()
Exemple #5
0
    def test_display_news(self):
        """
        The display_news method of the UI class will be tested to determine if
        the news was displayed correctly on the news window.
        """
        try:
            warnings.simplefilter("ignore", ResourceWarning)
            warnings.simplefilter("ignore", DeprecationWarning)

            ui = UI()

            # The starting position in the x-coordinate of the news window will
            # be rendered where the last window left off.
            x = int(curses.COLS / 5)

            # The width of the news window will occupy the remaining free space.
            height = curses.LINES
            width = curses.COLS - x

            # Window object: The window that will render the news content.
            news_window = ui.window(height, width, x, y=0)

            # String:           The news source used to fetch the news content.
            # Newspaper object: The news aggregator for the specified source.
            source = 'http://rss.nytimes.com/services/xml/rss/nyt/HomePage.xml'
            news = newspaper.build(source, memoize_articles=False)

            # Article object: The article parser for the news aggregator.
            article = news.articles[0]

            article.download()
            article.parse()

            ui.display_news(news_window, article, x=1, y=1, summary=True)
            ui.border(news_window)

            ui.display_news(news_window, article, x=1, y=1)
            ui.border(news_window)

        except(curses.error):
            ui.cleanup()
            traceback.print_exc()

            test = unittest.Testcase()
            test.fail()

        except(KeyboardInterrupt):
            ui.cleanup()

        else:
            ui.cleanup()