Example #1
0
def test_content_heading_true():
    """test menu generation for a defaulted value"""
    curses.initscr()
    curses.start_color()
    line_length = 100
    default = "dval"
    obj = {
        "__default": True,
        "__current_value": default,
        "default": default,
        "option": "test_option",
    }
    heading = content_heading(obj, line_length)
    assert len(heading) == 1
    assert len(heading[0]) == 1
    assert isinstance(heading[0][0], CursesLinePart)
    assert len(heading[0][0].string) == line_length + 1
    assert f"test option (current/default: {default})" in heading[0][0].string
    assert heading[0][0].color == curses.color_pair(curses.COLOR_GREEN)
    assert heading[0][0].column == 0
Example #2
0
def test_content_heading_false() -> None:
    """test menu generation for a value not default"""
    curses.initscr()
    curses.start_color()
    line_length = 100
    current = "cval"
    default = "dval"
    obj = {
        "__default": False,
        "__current_value": current,
        "default": default,
        "option": "test_option",
    }
    heading = content_heading(obj, line_length)
    assert heading
    assert len(heading) == 1
    assert len(heading[0]) == 1
    assert isinstance(heading[0][0], CursesLinePart)
    assert len(heading[0][0].string) == line_length + 1
    assert f"test option (current: {current})  (default: {default})" in heading[0][0].string
    assert heading[0][0].color == curses.COLOR_YELLOW
    assert heading[0][0].column == 0