File: test_mjunoon.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 (36 lines) | stat: -rw-r--r-- 1,841 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
import unittest
import requests_mock

from streamlink import Streamlink
from tests.mock import patch, Mock, ANY, call
from streamlink.plugins.mjunoon import Mjunoon


class TestPluginMixer(unittest.TestCase):
    def test_can_handle_url(self):
        # should match
        self.assertTrue(Mjunoon.can_handle_url('https://mjunoon.tv/news-live'))
        self.assertTrue(Mjunoon.can_handle_url('http://mjunoon.tv/watch/some-long-vod-name23456'))
        self.assertTrue(Mjunoon.can_handle_url('https://www.mjunoon.tv/other-live'))
        self.assertTrue(Mjunoon.can_handle_url('https://www.mjunoon.tv/watch/something-else-2321'))

    def test_can_handle_url_negative(self):
        # shouldn't match
        self.assertFalse(Mjunoon.can_handle_url('https://mjunoon.com'))

    @patch('streamlink.plugins.mjunoon.HLSStream.parse_variant_playlist')
    def test_get_streams(self, parse_variant_playlist):
        session = Streamlink()
        Mjunoon.bind(session, "test")
        script_text = """
        <script id="playerScript"  src="playerAssets/js/player.js?v=2.2&streamUrl=https://vod.mjunoon.tv:8181/live/41/41.m3u8&streamUrl=https://vod.mjunoon.tv:8181/live/17/17.m3u8"></script>
        """
        parse_variant_playlist.items.return_value = [("test", Mock())]
        with requests_mock.Mocker() as rmock:
            rmock.get("https://mjunoon.tv/news-live", text=script_text)
            plugin = Mjunoon("https://mjunoon.tv/news-live")
            _ = list(plugin.streams())
            self.assertSequenceEqual(
                [call(ANY, "https://vod.mjunoon.tv:8181/live/41/41.m3u8", params=dict(id=1), verify=False),
                 call(ANY, "https://vod.mjunoon.tv:8181/live/17/17.m3u8", params=dict(id=2), verify=False)],
                [parse_variant_playlist.mock_calls[0], parse_variant_playlist.mock_calls[3]])