def test_getpass_with_condition(self, hiden_stdin_mock, stdout_mock,
                                    stdin_mock):
        prompt = "Type input"
        wrong_input = "wrong"
        condition = lambda x, _: x != wrong_input
        hiden_stdin_mock.side_effect = self.input_generator()

        screen = GetPasswordInputScreen(message=prompt)
        screen.add_acceptance_condition(condition)

        self.schedule_screen_and_run(screen)

        self.assertTrue(self.correct_input)
Beispiel #2
0
    def test_uiscreen_password_disable_concurrency_check(
            self, input_handler_class_mock):
        # Replace default InputHandler instance created by InputManager by our mock to have
        # it stored after use.
        input_handler_instance_mock = InputHandlerMock()
        input_handler_class_mock.return_value = input_handler_instance_mock

        screen = GetPasswordInputScreen(message="Test prompt")
        input_manager = screen.input_manager
        input_manager.skip_concurrency_check = True
        screen.get_user_input("test")

        self.assertTrue(screen.input_manager.skip_concurrency_check)
        # Check that the created InputHandler instance has the flag correctly set.
        # We don't need to check the concurrency check functionality, it is tested
        # elsewhere already.
        self.assertTrue(input_handler_instance_mock.skip_concurrency_check)
    def test_getpass(self, hiden_stdin_mock, stdout_mock, stdin_mock):
        prompt = "Type input"
        input_text = "user input"
        screen = GetPasswordInputScreen(message=prompt)
        hiden_stdin_mock.return_value = input_text

        self.schedule_screen_and_run(screen)

        self.assertEqual(screen.value, input_text)
Beispiel #4
0
    def _ask_pass_modal(self, prompt, no_separator):
        pass_screen = GetPasswordInputScreen(prompt)
        pass_screen.no_separator = no_separator
        ScreenHandler.push_screen_modal(pass_screen)

        return pass_screen.value
Beispiel #5
0
    def _ask_pass_modal(self, prompt, no_separator):
        pass_screen = GetPasswordInputScreen(prompt)
        pass_screen.no_separator = no_separator
        ScreenHandler.push_screen_modal(pass_screen)

        return pass_screen.value