def test_HelpBar_init():
    mock_screen = MagicMock()
    mock_screen.getmaxyx.return_value = 50, 50
    test_bar = HelpBar(mock_screen)
    assert isinstance(test_bar, HelpBar)
    assert mock_screen.getmaxyx.called_once()
    assert hasattr(test_bar, 'help_string')
def test_HelpBar_draw():
    mock_screen = MagicMock()
    mock_screen.getmaxyx.return_value = 50, 50
    mock_help_string = "HELP"
    test_bar = HelpBar(mock_screen)
    test_bar.help_string = mock_help_string
    test_bar.draw()
    mock_screen.addstr.assert_called_with(49, 2, mock_help_string)
def test_HelpBar_build_help():
    mock_screen = MagicMock()
    mock_screen.getmaxyx.return_value = 50, 50
    mock_help_list = ["HELP", "MORE_HELP"]
    mock_help_print = "HELP"
    with patch('foolscap.display.render_composite.HELP_OPTIONS', mock_help_list):
        test_bar = HelpBar(mock_screen)
        test_bar.draw()
        mock_screen.addstr.assert_called_with(49, 2, mock_help_print)
def test_HelpBar_build_help_short_width():
    """ Test smaller console where no string can fit in console.
    """
    mock_screen = MagicMock()
    mock_screen.getmaxyx.return_value = 50, 6
    mock_help_list = ["HELP", "MORE_HELP"]
    mock_help_print = '--'.join(mock_help_list[:1])
    with patch('foolscap.display.render_composite.HELP_OPTIONS', mock_help_list):
        test_bar = HelpBar(mock_screen)
        test_bar.draw()
        mock_screen.addstr.assert_called_with(49, 2, '')
Beispiel #5
0
    def ui_collection(self):
        frame = Frame(self.screen)
        status_bar = StatusBar(self.screen, self.items, self.model)
        title_bar = TitleBar(self.screen)
        self.help_bar = HelpBar(self.screen)
        self.tabs = TabBar(self.screen, self.tab_title, self.books)
        if self.model.model_type == 'tags':
            self.tabs = TabBar(self.screen, self.model.model_type, self.books)
        self.menu = DisplayMenu(self.screen, self.items, self.model)

        self.render_objects = [
            frame, status_bar, title_bar, self.help_bar, self.tabs, self.menu
        ]
def test_HelpBar_next_hint():
    mock_screen = MagicMock()
    mock_screen.getmaxyx.return_value = 50, 50
    mock_help_list = ["HELP", "MORE_HELP"]
    with patch('foolscap.display.render_composite.HELP_OPTIONS', mock_help_list):
        test_bar = HelpBar(mock_screen)
        test_bar.draw()
        test_bar.next_hint()
        test_bar.update()
        test_bar.draw()
        test_bar.next_hint()
        test_bar.update()
        test_bar.draw()

        calls = [
            call(49, 2, "HELP"),
            call(49, 2, "MORE_HELP"),
            # Test it loops back to 0th item
            call(49, 2, "HELP"),
        ]
        mock_screen.addstr.assert_has_calls(calls)
def test_HelpBar_update():
    mock_screen = MagicMock()
    mock_screen.getmaxyx.return_value = 50, 50
    test_bar = HelpBar(mock_screen)
    assert mock_screen.getmaxyx.called_once()
    test_bar.update()