コード例 #1
0
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)
コード例 #2
0
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()