예제 #1
0
def test_conky_err_msg(monkeypatch):
    err = StringIO()
    monkeypatch.setattr(sys, 'stderr', err)
    cp = Printer(conky=True)
    cp.err_msg(_u('error'))
    err.seek(0)
    assert err.read() == _u('${color red}error')
예제 #2
0
def test_conky_debug_msg(monkeypatch):
    err = StringIO()
    monkeypatch.setattr(sys, 'stderr', err)
    cp = Printer(conky=True)
    cp.debug_msg(_u('debug'))
    err.seek(0)
    assert err.read() == _u('${color yellow}debug')
예제 #3
0
def test_debug_msg(monkeypatch):
    err = StringIO()
    monkeypatch.setattr(sys, 'stderr', err)
    cp = Printer()
    cp.debug_msg(_u('debug'))
    err.seek(0)
    assert err.read() == _u('\033[0;33mdebug\033[0m')
예제 #4
0
def test_err_msg(monkeypatch):
    err = StringIO()
    monkeypatch.setattr(sys, 'stderr', err)
    cp = Printer()
    cp.err_msg(_u('error'))
    err.seek(0)
    assert err.read() == _u('\033[31;1merror\033[0m')
예제 #5
0
def test_all_colors():
    """Makes sure the COLOR_NAMES is in sync with the colors in the printer"""
    cp = Printer()
    for color_name in COLOR_NAMES:
        out = StringIO()
        cp.msg(_u('msg'), color_name, file=out)
        out.seek(0)
        assert out.read() == _u(cp.colors[color_name] + 'msg' + '\033[0m')
예제 #6
0
def test_list(capsys, PatchedGCalI):
    gcal = PatchedGCalI(**vars(get_color_parser().parse_args([])))
    with open(TEST_DATA_DIR + '/cal_list.json') as cl:
        cal_count = len(load(cl)['items'])

    # test data has 6 cals
    assert cal_count == len(gcal.allCals)
    expected_header = gcal.printer.get_colorcode(
        gcal.options['color_title']) + ' Access  Title\n'

    gcal.ListAllCalendars()
    captured = capsys.readouterr()
    assert captured.out.startswith(_u(expected_header))

    # +3 cos one for the header, one for the '----' decorations,
    # and one for the eom
    assert len(captured.out.split('\n')) == cal_count + 3
예제 #7
0
def test_no_color():
    cp = Printer(use_color=False)
    out = StringIO()
    cp.msg(_u('msg'), 'red', file=out)
    out.seek(0)
    assert out.read() == _u('msg')
예제 #8
0
def test_conky_red_msg():
    cp = Printer(conky=True)
    out = StringIO()
    cp.msg(_u('msg'), 'red', file=out)
    out.seek(0)
    assert out.read() == _u('${color red}msg')
예제 #9
0
def test_red_msg():
    cp = Printer()
    out = StringIO()
    cp.msg(_u('msg'), 'red', file=out)
    out.seek(0)
    assert out.read() == _u('\033[0;31mmsg\033[0m')
예제 #10
0
def test_text_query(PatchedGCalI):
    gcal = PatchedGCalI()
    gcal.TextQuery(_u('test'))