-
Notifications
You must be signed in to change notification settings - Fork 7
/
query_cases.py
58 lines (47 loc) · 1.78 KB
/
query_cases.py
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
import os
import unittest
if 'test_url' in os.environ:
url = os.environ['test_url']
else:
url = 'cbsnews.com/live'
sample = '474000'
class TestCases(unittest.TestCase):
def probe(self, args, count):
'''Make actual query to the service. Redefined in child class'''
pass
def test_video(self):
'''Get video stream by implicit parameter'''
args = url
args += '+best'
self.assertTrue(self.probe(args, len(sample)//2).hex() == sample)
def test_url(self):
'''Get video stream by explicit parameter'''
args = 'url=' + url
args += '+best'
self.assertTrue(self.probe(args, len(sample)//2).hex() == sample)
def test_proxy(self):
'''Query for stream via proxy'''
if 'test_proxy' in os.environ:
args = url
args += '+best'
args += '&https-proxy=' + os.environ['test_proxy']
args += '&http-timeout=60'
self.assertTrue(self.probe(args, len(sample)//2).hex() == sample)
else:
self.assertTrue(True)
def test_path(self):
'''Drop last char from url to get exception.'''
args = url[:-1]
self.assertTrue('PluginError: ' in self.probe(args, None).decode())
def test_host(self):
'''Drop first char from url to get exception.'''
args = url[1:]
self.assertTrue(' NoPluginError: ' in self.probe(args, None).decode())
def test_streams(self):
'''Check for available streams (worst ... best)'''
args = url
self.assertTrue('Available streams: ' in self.probe(args, None).decode())
def test_help(self):
'''Pull out long help message'''
args = 'help'
self.assertTrue('Streamlink\'s session options.' in self.probe(args, None).decode())