Example #1
0
 def check(s):
     self.m1.reset_mock()
     self.m1.return_value = s
     handler = InputHandler()
     handler.start()
     handler.input_number()
     handler.end()
Example #2
0
 def test_raise_on_incorrect_right_border_of_range_in_number_input(self):
     i1, i2 = '2', 1
     self.m1.return_value = i1
     handler = InputHandler()
     handler.start()
     with self.assertRaises(InputNumRangeError, msg=(i1, i2)):
         handler.input_number(number_max=i2)
     handler.end()
Example #3
0
 def test_can_replace_default_prompt_for_number_input(self):
     handler = InputHandler()
     handler.start(number_prompt='a')
     handler.input_number()
     handler.input_number(prompt='b')
     handler.end()
     self.m1.assert_any_call('a')
     self.m1.assert_any_call('b')
Example #4
0
 def test_can_set_several_default_prompts_for_inputs(self):
     handler = InputHandler()
     handler.start(number_prompt='a',
                   password_prompt='b',
                   string_prompt='c')
     handler.input_number()
     handler.input_password()
     handler.input_string()
     handler.end()
     self.m1.assert_any_call('a')
     self.m1.assert_any_call('c')
     self.m2.assert_called_once_with('b')
Example #5
0
    def test_can_see_borders_of_range_in_number_input(self):
        self.m1.return_value = '1'
        handler = InputHandler()
        handler.start()
        res = handler.input_number(1, 3)
        handler.end()
        self.assertEqual(res, 1, msg=res)

        self.m1.return_value = '3'
        handler = InputHandler()
        handler.start()
        res = handler.input_number(1, 3)
        handler.end()
        self.assertEqual(res, 3, msg=res)
Example #6
0
 def test_can_set_only_right_border_of_range_in_number_input(self):
     self.m1.return_value = '1'
     handler = InputHandler()
     handler.start()
     res = handler.input_number(number_max=10)
     handler.end()
     self.assertEqual(res, 1, msg=res)
Example #7
0
 def test_can_input_a_number_in_range_in_number_input(self):
     self.m1.return_value = '5'
     handler = InputHandler()
     handler.start()
     res = handler.input_number(1, 10)
     handler.end()
     self.assertEqual(res, 5, msg=res)
Example #8
0
 def test_can_set_empty_default_prompt_for_number_input(self):
     handler = InputHandler()
     handler.start()
     handler.input_number()
     handler.end()
     self.m1.assert_called_once_with('')
Example #9
0
 def check(s, start, end):
     self.m1.return_value = s
     handler = InputHandler()
     handler.start()
     handler.input_number(start, end)
     handler.end()