Exemplo n.º 1
0
    def test_handle_stream_output_stream(self, args: Mock,
                                         mock_output_stream: Mock):
        """
        Test that the formatter does define the correct variables
        """
        args.json = False
        args.subprocess_cmdline = False
        args.stream_url = False
        args.output = False
        args.stdout = False
        args.url = "URL"
        args.player_passthrough = []
        args.player_external_http = False
        args.player_continuous_http = False
        mock_output_stream.return_value = True

        plugin = _TestPlugin("")
        plugin.author = "AUTHOR"
        plugin.category = "CATEGORY"
        plugin.title = "TITLE"
        stream = Stream(session=Mock())
        streams = {"best": stream}

        handle_stream(plugin, streams, "best")
        self.assertEqual(mock_output_stream.call_count, 1)
        paramStream, paramFormatter = mock_output_stream.call_args[0]
        self.assertIs(paramStream, stream)
        self.assertIsInstance(paramFormatter, Formatter)
        self.assertEqual(
            paramFormatter.title(
                "{url} - {author} - {category}/{game} - {title}"),
            "URL - AUTHOR - CATEGORY/CATEGORY - TITLE")
Exemplo n.º 2
0
 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: ")
Exemplo n.º 3
0
 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")
Exemplo n.º 4
0
 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')
Exemplo n.º 5
0
 def test_user_input_bad_class(self):
     p = _TestPlugin("http://example.com/stream")
     self.assertRaises(RuntimeError, p.bind, self.session, 'test_plugin',
                       object())