File: test_ustreamtv.py

package info (click to toggle)
streamlink 1.0.0%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 3,588 kB
  • sloc: python: 31,121; makefile: 141; sh: 93
file content (43 lines) | stat: -rw-r--r-- 1,362 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
import unittest

from streamlink import Streamlink

try:
    from unittest.mock import ANY, MagicMock, call
except ImportError:
    from mock import ANY, MagicMock, call
from streamlink.plugins.ustreamtv import UStreamTV


class TestPluginUStreamTV(unittest.TestCase):
    def test_can_handle_url(self):
        should_match = [
            "http://www.ustream.tv/streamlink",
            "http://www.ustream.tv/channel/id/1234",
            "http://www.ustream.tv/embed/1234",
            "http://www.ustream.tv/recorded/6543",
            "http://www.ustream.tv/embed/recorded/6543",
        ]
        for url in should_match:
            self.assertTrue(UStreamTV.can_handle_url(url))

        should_not_match = [
            "https://www.youtube.com/v/aqz-KE-bpKQ",
        ]
        for url in should_not_match:
            self.assertFalse(UStreamTV.can_handle_url(url))

    def test_arguments(self):
        from streamlink_cli.main import setup_plugin_args
        session = Streamlink()
        parser = MagicMock()
        plugin_parser = MagicMock()
        parser.add_argument_group = MagicMock(return_value=plugin_parser)

        session.plugins = {
            'ustreamtv': UStreamTV
        }

        setup_plugin_args(session, parser)

        plugin_parser.add_argument.assert_called_with('--ustream-password', metavar="PASSWORD", help=ANY)