def test_get_response_options(self, mock_print, mock_input): mock_input.side_effect = ['mistake', 'y'] get_response('A question', ('y', 'n')) mock_input.assert_has_calls([call()] * 2) mock_print.assert_has_calls([call('A question'), call("Permitted responses: ('y', 'n')"), call('Invalid response, try again!')])
def test_get_response_options(self, mock_log, mock_input): mock_input.side_effect = ["mistake", "y"] get_response("A question", ("y", "n")) mock_input.assert_has_calls([call()] * 2) mock_log.info.assert_has_calls( [call("A question"), call("Permitted responses: ('y', 'n')")]) mock_log.error.assert_called_with("Invalid response, try again!")
def test_get_response_password(self, mock_print, mock_input, mock_getpass): mock_getpass.side_effect = ["A password"] answer = get_response("A question", sensitive=True) mock_input.assert_not_called() mock_print.assert_called_with("A question") mock_getpass.assert_called_once_with("Password:"******"A password"
def test_get_response_password(self, mock_print, mock_input, mock_getpass): mock_getpass.side_effect = ['A password'] answer = get_response('A question', sensitive=True) mock_input.assert_not_called() mock_print.assert_called_with('A question') mock_getpass.assert_called_once_with('Password:'******'A password'
def test_get_response(self, mock_print, mock_input): mock_input.side_effect = ["An answer"] answer = get_response("A question") mock_input.assert_called_once() mock_print.assert_called_with("A question") assert answer == "An answer"
def test_get_response(self, mock_print, mock_input): mock_input.side_effect = ['An answer'] answer = get_response('A question') mock_input.assert_called_once() mock_print.assert_called_with('A question') assert answer == 'An answer'