Ejemplo n.º 1
0
def test_command_set_running():
    cmd = Command('test1', 1, Mock())
    cmd.set_running(False)
    eq_(False, cmd.active)

    cmd.set_running(True)
    eq_(True, cmd.active)
Ejemplo n.º 2
0
def test_pad_draw_header_with_diff(curses_mock, time_mock):
    time_mock.ctime.return_value = ctime = 'Tue Mar 25 21:00:00 2014'
    layout = EvenVerticalLayout()
    command = Command('test', 1, Mock())
    pane = Pane(0, 25, 80, layout)
    pane.show_diffs = True
    pane.draw_header(command)
    curses_mock.newpad().addstr.assert_has_calls([
        call(0, 0, ANY, ANY),
        call(0, 2, '1', ANY),
        call(0, 4, 'test', curses_mock.color_pair(3)),
        call(0, 9, 'diff last', curses_mock.color_pair(1)),
        call(0, 55, ctime)
    ])
    curses_mock.reset()

    command.mark = 'test'
    pane.draw_header(command)
    curses_mock.newpad().addstr.assert_has_calls([
        call(0, 0, ANY, ANY),
        call(0, 2, '1', ANY),
        call(0, 4, 'test', curses_mock.color_pair(3)),
        call(0, 9, 'diff mark', curses_mock.color_pair(1)),
        call(0, 55, ctime)
    ])
Ejemplo n.º 3
0
def test_command_toggle_running():
    cmd = Command('test1', 1, Mock())
    cmd.toggle_running()
    eq_(False, cmd.active)

    cmd.toggle_running()
    eq_(True, cmd.active)
Ejemplo n.º 4
0
def test_cmd_mark_diff(curses_mock):
    cmd1 = Command('test1', 1, Mock())
    cmd2 = Command('test2', 2, Mock())
    watch = Watch(Mock(height=20, width=80), Mock(), [cmd1, cmd2], Mock())

    eq_(None, cmd1.mark)

    cmd1.content = ['test\noutput\n']
    rolex.cmd_mark_diff(watch, None)

    eq_(['test', 'output'], cmd1.mark)
Ejemplo n.º 5
0
def test_pad_draw_header_inactive(curses_mock, time_mock):
    time_mock.ctime.return_value = ctime = 'Tue Mar 25 21:00:00 2014'
    layout = EvenVerticalLayout()
    command = Command('test', 1, Mock())
    command.active = False
    Pane(0, 25, 80, layout).draw_header(command)
    curses_mock.newpad().addstr.assert_has_calls([
        call(0, 0, ANY, ANY),
        call(0, 2, '1', ANY),
        call(0, 4, 'test', curses_mock.color_pair(4) | curses_mock.A_BOLD),
        call(0, 55, ctime)
    ])
Ejemplo n.º 6
0
def test_pad_draw_header_on_change(curses_mock, time_mock):
    time_mock.ctime.return_value = ctime = 'Tue Mar 25 21:00:00 2014'
    layout = EvenVerticalLayout()
    command = Command('test', 1, Mock())
    command.on_change = ('exit',)
    Pane(0, 25, 80, layout).draw_header(command)
    curses_mock.newpad().addstr.assert_has_calls([
        call(0, 0, ANY, ANY),
        call(0, 2, '1', ANY),
        call(0, 4, 'test', curses_mock.color_pair(3)),
        call(0, 9, 'chg:exit', curses_mock.color_pair(1)),
        call(0, 55, ctime)
    ])
Ejemplo n.º 7
0
def test_cmd_toggle_diffs(curses_mock):
    cmd1 = Command('test1', 1, Mock())
    cmd2 = Command('test2', 2, Mock())
    watch = Watch(Mock(height=20, width=80), Mock(), [cmd1, cmd2], Mock())

    cmd1.mark = Mock()
    watch.panes[0].show_diffs = True

    rolex.cmd_toggle_diffs(watch, None)

    eq_(None, cmd1.mark)
    eq_(False, watch.panes[0].show_diffs)

    rolex.cmd_toggle_diffs(watch, None)

    eq_(None, cmd1.mark)
    eq_(True, watch.panes[0].show_diffs)
Ejemplo n.º 8
0
def test_cmd_toggle_pause(curses_mock):
    cmd1 = Command('test1', 1, Mock())
    cmd2 = Command('test2', 2, Mock())
    watch = Watch(Mock(height=20, width=80), Mock(), [cmd1, cmd2], Mock())

    eq_(True, all(cmd.active for cmd in watch.commands))

    rolex.cmd_toggle_pause(watch, None)

    eq_(False, any(cmd.active for cmd in watch.commands))

    cmd1.active = True
    rolex.cmd_toggle_pause(watch, None)

    eq_(True, any(cmd.active for cmd in watch.commands))

    cmd1.active = False
    rolex.cmd_toggle_pause(watch, None)

    eq_(True, any(cmd.active for cmd in watch.commands))
Ejemplo n.º 9
0
def test_command_diff_mark():
    cmd = Command('test', 1, Mock())
    eq_(None, cmd.diff_base_output)

    cmd.set_diff_mark()
    eq_(None, cmd.diff_base_output)

    cmd.content.append('test\noutput')
    cmd.set_diff_mark()
    eq_(['test', 'output'], cmd.diff_base_output)

    cmd.clear_diff_mark()
    eq_(None, cmd.diff_base_output)
Ejemplo n.º 10
0
def test_command_get_output_error():
    cmd = Command('false', 1, Mock())
    assert cmd._get_output()[0].startswith("Error running 'false'")
Ejemplo n.º 11
0
def test_command_get_output():
    cmd = Command('echo "test"', 1, Mock())
    eq_(("test\n", True), cmd._get_output())
Ejemplo n.º 12
0
def _verify_command_change_period(start, adjustment, expected):
    cmd = Command('test', start, Mock())
    eq_(start, cmd.period)
    cmd.change_period(adjustment)
    eq_(expected, cmd.period)