1
0
mirror of https://github.com/spaam/svtplay-dl.git synced 2024-11-27 21:54:17 +01:00

hls: Break out get_full_url tests to new test suite (http)

The get_full_url was moved some time ago from the hls module to the
svtplay_dl.utils.http module.
This commit is contained in:
Olof Johansson 2018-09-08 22:48:53 +02:00 committed by Johan Andersson
parent 228d34c500
commit bbf10ee077
2 changed files with 51 additions and 44 deletions

View File

@ -10,7 +10,6 @@
from __future__ import absolute_import from __future__ import absolute_import
import unittest import unittest
import svtplay_dl.fetcher.hls as hls
from svtplay_dl.fetcher.hls import M3U8 from svtplay_dl.fetcher.hls import M3U8
# Example HLS playlist, source: # Example HLS playlist, source:
@ -37,49 +36,6 @@ something0/else.m3u8
class HlsTest(unittest.TestCase): class HlsTest(unittest.TestCase):
def test_get_full_url_1(self):
for test in [
# full http:// url as media segment in playlist
{
'srcurl': 'INVALID',
'segment': 'http://example.com/',
'expected': 'http://example.com/'
},
# full https:// url as media segment in playlist
{
'srcurl': 'INVALID',
'segment': 'https://example.com/',
'expected': 'https://example.com/'
},
# filename as media segment in playlist (http)
{
'srcurl': 'http://example.com/',
'segment': 'foo.ts',
'expected': 'http://example.com/foo.ts'
},
# filename as media segment in playlist (https)
{
'srcurl': 'https://example.com/',
'segment': 'foo.ts',
'expected': 'https://example.com/foo.ts'
},
# replacing srcurl file
{
'srcurl': 'http://example.com/bar',
'segment': 'foo.ts',
'expected': 'http://example.com/foo.ts'
},
# with query parameters
{
'srcurl': 'http://example.com/bar?baz=qux',
'segment': 'foo.ts',
'expected': 'http://example.com/foo.ts'
},
]:
self.assertEqual(
hls._get_full_url(test['segment'], test['srcurl']),
test['expected'])
def test_parse_m3u8(self): def test_parse_m3u8(self):
self.maxDiff = None self.maxDiff = None
for test in [ for test in [

View File

@ -0,0 +1,51 @@
#!/usr/bin/python
# ex:ts=4:sw=4:sts=4:et
# -*- tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*-
import unittest
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
{
'srcurl': 'INVALID',
'segment': 'http://example.com/',
'expected': 'http://example.com/'
},
# full https:// url as media segment in playlist
{
'srcurl': 'INVALID',
'segment': 'https://example.com/',
'expected': 'https://example.com/'
},
# filename as media segment in playlist (http)
{
'srcurl': 'http://example.com/',
'segment': 'foo.ts',
'expected': 'http://example.com/foo.ts'
},
# filename as media segment in playlist (https)
{
'srcurl': 'https://example.com/',
'segment': 'foo.ts',
'expected': 'https://example.com/foo.ts'
},
# replacing srcurl file
{
'srcurl': 'http://example.com/bar',
'segment': 'foo.ts',
'expected': 'http://example.com/foo.ts'
},
# with query parameters
{
'srcurl': 'http://example.com/bar?baz=qux',
'segment': 'foo.ts',
'expected': 'http://example.com/foo.ts'
},
]:
self.assertEqual(
get_full_url(test['segment'], test['srcurl']),
test['expected'])