Exemplo n.º 1
0
 def test_get_lines(self):
     title = 'Please choose an option: '
     options = ['option1', 'option2', 'option3']
     picker = Picker(options, title, indicator='*')
     lines, current_line = picker.get_lines()
     assert lines == [title, '', '* option1', '  option2', '  option3']
     assert current_line == 3
Exemplo n.º 2
0
 def test_get_lines(self):
     title = 'Please choose an option: '
     options = ['option1', 'option2', 'option3']
     picker = Picker(options, title, indicator='*')
     lines, current_line = picker.get_lines()
     assert lines == [title, '', '* option1', '  option2', '  option3']
     assert current_line == 3
Exemplo n.º 3
0
    def test_options_map_func(self):
        title = 'Please choose an option: '
        options = [{'label': 'option1'}, {'label': 'option2'}, {'label': 'option3'}]

        def get_label(option): return option.get('label')

        picker = Picker(options, title, indicator='*', options_map_func=get_label)
        lines, current_line = picker.get_lines()
        assert lines == [title, '', '* option1', '  option2', '  option3']
        assert picker.get_selected() == ({ 'label': 'option1' }, 0)
Exemplo n.º 4
0
 def test_no_title(self):
     options = ['option1', 'option2', 'option3']
     picker = Picker(options)
     lines, current_line = picker.get_lines()
     assert current_line == 1
Exemplo n.º 5
0
 def test_no_title(self):
     options = ['option1', 'option2', 'option3']
     picker = Picker(options)
     lines, current_line = picker.get_lines()
     assert current_line == 1