def test_user_input_console(self): p = _TestPlugin("http://example.com/stream") with self._mock_console_input() as console_input: p.bind(self.session, 'test_plugin', console_input) self.assertEqual("username", p.input_ask("username")) self.assertEqual("password", p.input_ask_password("password")) console_input.console.ask.assert_called_with("username: "******"password: ")
def test_user_input_console_no_tty(self): p = _TestPlugin("http://example.com/stream") with self._mock_console_input(isatty=False) as console_input: p.bind(self.session, 'test_plugin', console_input) self.assertRaises(PluginError, p.input_ask, "username") self.assertRaises(PluginError, p.input_ask_password, "password")
def test_user_input_not_implemented(self): p = _TestPlugin("http://example.com/stream") p.bind(self.session, 'test_plugin', UserInputRequester()) self.assertRaises(PluginError, p.input_ask, 'test') self.assertRaises(PluginError, p.input_ask_password, 'test')
def test_user_input_bad_class(self): p = _TestPlugin("http://example.com/stream") self.assertRaises(RuntimeError, p.bind, self.session, 'test_plugin', object())