Esempio n. 1
0
 def draw_sources_list(self):
     height, width = self.screen.getmaxyx()
     used_width = DEFAULT_LIST_WIDTH
     prototype_line = "{:^6.6s}| {:40.40s}| {:30.30s}"
     draw_full_line(self.screen, 2,
                    prototype_line.format("Id", "Name", "Last timestamp"))
     self.screen.addstr(3, 0, "-" * used_width)
     if width < used_width:
         used_width = width
     used_height = DEFAULT_LIST_ROWS
     if used_height + 3 > height:
         used_height = height - 3
     sources_win = curses.newwin(used_height, used_width, 4, 0)
     win_height, win_width = sources_win.getmaxyx()
     available_rows = win_height
     sources_to_list, selection_row = generate_list(self.known_sources,
                                                    available_rows,
                                                    self.selected_item)
     for i, item in enumerate(sources_to_list):
         selected = False
         if i == selection_row:
             selected = True
         if type(item) is str:
             draw_full_line(sources_win, i, "  " + item * 3)
         else:
             draw_full_line(
                 sources_win, i,
                 prototype_line.format(item.source_type, item.source_name,
                                       time_to_str(item.last_timestamp)),
                 selected)
     sources_win.refresh()
Esempio n. 2
0
def test_fewer_items_than_rows():
    nr_of_rows = 5
    items = list(range(3))
    for i in items:
        rows, selected_row = generate_list(items, nr_of_rows, i)
        assert rows == items
        assert selected_row == i
Esempio n. 3
0
def test_same_number_of_rows_and_items():
    nr_of_rows = 5
    items = list(range(5))
    for i in items:
        rows, selected_row = generate_list(items, nr_of_rows, i)
        assert rows == items
        assert selected_row == i
Esempio n. 4
0
def test_two_more_items_sel_456(selection):
    nr_of_rows = 5
    items = list(range(7))
    rows, selected_row = generate_list(items, nr_of_rows, selection)
    assert rows == [
        "↑",
        3,
        4,
        5,
        6,
    ]
    assert selected_row == selection - 2
"""
Explain how output_list name will affect this program if it is used as global variable
"""
from list_generator import generate_list
from list_to_set import convert_list_to_set

my_list = []
my_list = generate_list()
my_set = convert_list_to_set(my_list)
input("program executed!")
Esempio n. 6
0
def test_two_more_items_sel_3():
    nr_of_rows = 5
    items = list(range(7))
    rows, selected_row = generate_list(items, nr_of_rows, 3)
    assert rows == ["↑", 2, 3, 4, "↓"]
    assert selected_row == 3 - 1
Esempio n. 7
0
def test_two_more_items_sel_012(selection):
    nr_of_rows = 5
    items = list(range(7))
    rows, selected_row = generate_list(items, nr_of_rows, selection)
    assert rows == [0, 1, 2, 3, "↓"]
    assert selected_row == selection
Esempio n. 8
0
def test_one_more_item_sel_345(selection):
    nr_of_rows = 5
    items = list(range(6))
    rows, selected_row = generate_list(items, nr_of_rows, selection)
    assert rows == ["↑", 2, 3, 4, 5]
    assert selected_row == selection - 1
Esempio n. 9
0
def test_empty_list():
    rows, selected_row = generate_list([], 10, -1)
    assert rows == []
    assert selected_row == -1