Exemple #1
0
 def test_menu_run_exit(self) -> None:
     menu = Menu(items=[{
         "label": "a",
         "callback": a
     }],
                 exit_callback=lambda: None)
     self.assertEqual(None, menu.run_choice(1))
Exemple #2
0
 def test_set_colors(self) -> None:
     menu = Menu(items=[{"label": "a", "callback": a}])
     menu.set_colors(
         num_bold=True,
         num_bg="black",
         num_fg="red",
         label_bold=True,
         label_bg="black",
         label_fg="red",
     )
Exemple #3
0
 def test_menu_add_item_kwargs_no_label(self) -> None:
     menu = Menu()
     menu.add_item(callback=a)
     self.assertEqual(
         menu.items,
         [
             {
                 "args": (),
                 "callback": sys.exit,
                 "kwargs": {},
                 "label": "Exit"
             },
             {
                 "args": (),
                 "callback": a,
                 "kwargs": {},
                 "label": "a"
             },
         ],
     )
Exemple #4
0
 def test_menu_with_exit_message(self) -> None:
     menu = Menu(exit_msg="test")
     self.assertEqual(
         menu.exit_item,
         {
             "args": (),
             "callback": sys.exit,
             "kwargs": {},
             "label": "test"
         },
     )
Exemple #5
0
 def test_menu_add_value_item(self) -> None:
     menu = Menu()
     menu.add_value_item(1)
     self.assertEqual(
         menu.items,
         [
             {
                 "args": (),
                 "callback": sys.exit,
                 "kwargs": {},
                 "label": "Exit"
             },
             {
                 "args": (1, ),
                 "callback": menu._value_callback,
                 "kwargs": {},
                 "label": "1",
             },
         ],
     )
Exemple #6
0
 def test_menu_with_items_list(self) -> None:
     menu = Menu(items=[{"label": "a", "callback": a}])
     self.assertEqual(
         menu.items,
         [
             {
                 "args": (),
                 "callback": a,
                 "kwargs": {},
                 "label": "a"
             },
             {
                 "args": (),
                 "callback": sys.exit,
                 "kwargs": {},
                 "label": "Exit"
             },
         ],
     )
Exemple #7
0
 def test_print_row(self) -> None:
     menu = Menu(items=[{"label": "a", "callback": a}])
     menu.print_row(0, "test")
Exemple #8
0
 def test_value_callback(self) -> None:
     menu = Menu()
     self.assertEqual(menu._value_callback(1), 1)
Exemple #9
0
 def test_menu_run_choice(self) -> None:
     menu = Menu(items=[{"label": "a", "callback": a}])
     self.assertEqual(None, menu.run_choice(0))
Exemple #10
0
 def test_menu_run_out_of_range(self) -> None:
     menu = Menu(items=[{"label": "a", "callback": a}])
     with self.assertRaises(TypeError):
         self.assertEqual(menu.run(choose_msg="test"), None)
Exemple #11
0
 def test_menu_run(self) -> None:
     menu = Menu(items=[{"label": "a", "callback": a}])
     self.assertEqual(menu.run(choose_msg="test"), None)
Exemple #12
0
 def test_menu_get_input(self) -> None:
     menu = Menu()
     self.assertEqual(menu._get_input(), "13")
Exemple #13
0
 def test_menu_print_rows(self) -> None:
     menu = Menu()
     menu._print_rows()
Exemple #14
0
 def test_menu_print_header(self) -> None:
     menu = Menu()
     self.assertIsNone(menu._print_header("header"))
Exemple #15
0
 def test_menu_input_check(self) -> None:
     menu = Menu()
     self.assertEqual(menu._check_input("1"), 1)
     self.assertEqual(menu._check_input("a"), None)
     self.assertEqual(menu._check_input("4"), None)
Exemple #16
0
 def test_menu_clear(self) -> None:
     menu = Menu()
     self.assertTrue(menu.clear())