File: test_qq.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 (41 lines) | stat: -rw-r--r-- 1,251 bytes parent folder | download | duplicates (2)
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
import unittest

from streamlink.plugins.qq import QQ


class TestPluginQQ(unittest.TestCase):
    def test_can_handle_url(self):
        should_match = [
            "http://live.qq.com/10003715",
            "http://live.qq.com/10007266",
            "http://live.qq.com/10039165",
            "http://m.live.qq.com/10003715",
            "http://m.live.qq.com/10007266",
            "http://m.live.qq.com/10039165"
        ]
        for url in should_match:
            self.assertTrue(QQ.can_handle_url(url))

        should_not_match = [
            "http://live.qq.com/",
            "http://qq.com/",
            "http://www.qq.com/"
        ]
        for url in should_not_match:
            self.assertFalse(QQ.can_handle_url(url))

    def test_url_re(self):
        regex_match_list = [
            {
                "data": "http://live.qq.com/10003715",
                "result": "10003715"
            },
            {
                "data": "http://m.live.qq.com/10039165",
                "result": "10039165"
            }
        ]
        for m_test in regex_match_list:
            m = QQ._url_re.match(m_test.get("data"))
            self.assertIsNotNone(m)
            self.assertEqual(m_test.get("result"), m.group("room_id"))