mirror of
https://github.com/spaam/svtplay-dl.git
synced 2024-11-23 19:55:38 +01:00
test: add tests for service_handler
This commit is contained in:
parent
dc8e62103f
commit
c08e5460fe
@ -1,8 +1,3 @@
|
||||
#!/usr/bin/python
|
||||
# ex:ts=4:sw=4:sts=4:et
|
||||
# -*- tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*-
|
||||
# The unittest framwork doesn't play nice with pylint:
|
||||
# pylint: disable-msg=C0103
|
||||
from __future__ import absolute_import
|
||||
|
||||
import unittest
|
||||
@ -20,40 +15,40 @@ class MockService(Service):
|
||||
|
||||
class ServiceTest(unittest.TestCase):
|
||||
def test_supports(self):
|
||||
self.assertTrue(MockService.handles("http://example.com/video.swf?id=1"))
|
||||
self.assertTrue(MockService.handles("http://example.net/video.swf?id=1"))
|
||||
self.assertTrue(MockService.handles("http://www.example.com/video.swf?id=1"))
|
||||
self.assertTrue(MockService.handles("http://www.example.net/video.swf?id=1"))
|
||||
assert MockService.handles("http://example.com/video.swf?id=1")
|
||||
assert MockService.handles("http://example.net/video.swf?id=1")
|
||||
assert MockService.handles("http://www.example.com/video.swf?id=1")
|
||||
assert MockService.handles("http://www.example.net/video.swf?id=1")
|
||||
|
||||
|
||||
class service_handlerTest(unittest.TestCase):
|
||||
def test_service_handler(self):
|
||||
config = setup_defaults()
|
||||
self.assertIsNone(service_handler(sites, config, "localhost"))
|
||||
assert not service_handler(sites, config, "localhost")
|
||||
|
||||
|
||||
class service_handlerTest2(unittest.TestCase):
|
||||
def test_service_handler(self):
|
||||
config = setup_defaults()
|
||||
self.assertIsInstance(service_handler(sites, config, "https://www.svtplay.se"), Service)
|
||||
assert isinstance(service_handler(sites, config, "https://www.svtplay.se"), Service)
|
||||
|
||||
|
||||
class service_opengraphGet(unittest.TestCase):
|
||||
text = '<html><head><meta name="og:image" property="og:image" content="http://example.com/img3.jpg"><meta'
|
||||
|
||||
def test_og_get(self):
|
||||
self.assertEqual(opengraph_get(self.text, "image"), "http://example.com/img3.jpg")
|
||||
assert opengraph_get(self.text, "image") == "http://example.com/img3.jpg"
|
||||
|
||||
|
||||
class service_opengraphGet_none(unittest.TestCase):
|
||||
text = '<html><head><meta name="og:image" property="og:image" content="http://example.com/img3.jpg"><meta'
|
||||
|
||||
def test_og_get(self):
|
||||
self.assertIsNone(opengraph_get(self.text, "kalle"))
|
||||
assert not opengraph_get(self.text, "kalle")
|
||||
|
||||
|
||||
class service_opengraphGet2(unittest.TestCase):
|
||||
text = '<html><head><meta name="og:image" property="og:image" content="http://example.com/img3.jpg">'
|
||||
|
||||
def test_og_get(self):
|
||||
self.assertEqual(opengraph_get(self.text, "image"), "http://example.com/img3.jpg")
|
||||
assert opengraph_get(self.text, "image") == "http://example.com/img3.jpg"
|
Loading…
Reference in New Issue
Block a user