MCPcopy
hub / github.com/beetbox/beets / test_input_select_objects

Method test_input_select_objects

test/ui/test_ui_init.py:36–86  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

34 print(prefix, s)
35
36 def test_input_select_objects(self):
37 full_items = ["1", "2", "3", "4", "5"]
38
39 # Test no
40 self.io.addinput("n")
41 items = ui.input_select_objects(
42 "Prompt", full_items, self._print_helper
43 )
44 assert items == []
45
46 # Test yes
47 self.io.addinput("y")
48 items = ui.input_select_objects(
49 "Prompt", full_items, self._print_helper
50 )
51 assert items == full_items
52
53 # Test selective 1
54 self.io.addinput("s")
55 self.io.addinput("n")
56 self.io.addinput("y")
57 self.io.addinput("n")
58 self.io.addinput("y")
59 self.io.addinput("n")
60 items = ui.input_select_objects(
61 "Prompt", full_items, self._print_helper
62 )
63 assert items == ["2", "4"]
64
65 # Test selective 2
66 self.io.addinput("s")
67 self.io.addinput("y")
68 self.io.addinput("y")
69 self.io.addinput("n")
70 self.io.addinput("y")
71 self.io.addinput("n")
72 items = ui.input_select_objects(
73 "Prompt", full_items, lambda s: self._print_helper2(s, "Prefix")
74 )
75 assert items == ["1", "2", "4"]
76
77 # Test selective 3
78 self.io.addinput("s")
79 self.io.addinput("y")
80 self.io.addinput("n")
81 self.io.addinput("y")
82 self.io.addinput("q")
83 items = ui.input_select_objects(
84 "Prompt", full_items, self._print_helper
85 )
86 assert items == ["1", "3"]
87
88
89class ParentalDirCreation(IOMixin, BeetsTestCase):

Callers

nothing calls this directly

Calls 2

_print_helper2Method · 0.95
addinputMethod · 0.80

Tested by

no test coverage detected