2018-09-08 22:48:53 +02:00
|
|
|
#!/usr/bin/python
|
|
|
|
# ex:ts=4:sw=4:sts=4:et
|
|
|
|
# -*- tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*-
|
|
|
|
import unittest
|
2019-08-25 00:40:39 +02:00
|
|
|
|
2018-09-08 22:48:53 +02:00
|
|
|
from svtplay_dl.utils.http import get_full_url
|
|
|
|
|
|
|
|
|
|
|
|
class HttpTest(unittest.TestCase):
|
|
|
|
def test_get_full_url_1(self):
|
|
|
|
for test in [
|
|
|
|
# full http:// url as media segment in playlist
|
2019-09-06 22:49:49 +02:00
|
|
|
{"srcurl": "INVALID", "segment": "http://example.com/", "expected": "http://example.com/"},
|
2018-09-08 22:48:53 +02:00
|
|
|
# full https:// url as media segment in playlist
|
2019-09-06 22:49:49 +02:00
|
|
|
{"srcurl": "INVALID", "segment": "https://example.com/", "expected": "https://example.com/"},
|
2018-09-08 22:48:53 +02:00
|
|
|
# filename as media segment in playlist (http)
|
2019-09-06 22:49:49 +02:00
|
|
|
{"srcurl": "http://example.com/", "segment": "foo.ts", "expected": "http://example.com/foo.ts"},
|
2018-09-08 22:48:53 +02:00
|
|
|
# filename as media segment in playlist (https)
|
2019-09-06 22:49:49 +02:00
|
|
|
{"srcurl": "https://example.com/", "segment": "foo.ts", "expected": "https://example.com/foo.ts"},
|
2018-09-08 22:48:53 +02:00
|
|
|
# replacing srcurl file
|
2019-09-06 22:49:49 +02:00
|
|
|
{"srcurl": "http://example.com/bar", "segment": "foo.ts", "expected": "http://example.com/foo.ts"},
|
2018-09-08 22:48:53 +02:00
|
|
|
# with query parameters
|
2019-09-06 22:49:49 +02:00
|
|
|
{"srcurl": "http://example.com/bar?baz=qux", "segment": "foo.ts", "expected": "http://example.com/foo.ts"},
|
2019-09-07 12:27:36 +02:00
|
|
|
# with segment with slash
|
|
|
|
{"srcurl": "http://example.com/bar", "segment": "/test", "expected": "http://example.com/test"},
|
2018-09-08 22:48:53 +02:00
|
|
|
]:
|
2019-08-31 01:02:59 +02:00
|
|
|
assert get_full_url(test["segment"], test["srcurl"]) == test["expected"]
|