mirror of
https://github.com/Hopiu/django-embed-video.git
synced 2026-05-11 06:03:10 +00:00
Tests for CustomBackend
This commit is contained in:
parent
acd0dbf9c8
commit
2a4fe971b5
4 changed files with 48 additions and 6 deletions
11
embed_video/tests/custom_backend.py
Normal file
11
embed_video/tests/custom_backend.py
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
import re
|
||||
|
||||
from embed_video.backends import VideoBackend
|
||||
|
||||
|
||||
class CustomBackend(VideoBackend):
|
||||
re_detect = re.compile(r'http://myvideo\.com/[0-9]+')
|
||||
re_code = re.compile(r'http://myvideo\.com/(?P<code>[0-9]+)')
|
||||
|
||||
pattern_url = 'http://play.myvideo.com/c/%s/'
|
||||
pattern_thumbnail_url = 'http://thumb.myvideo.com/c/%s/'
|
||||
|
|
@ -12,13 +12,22 @@ INSTALLED_APPS = (
|
|||
'embed_video',
|
||||
)
|
||||
|
||||
|
||||
EMBED_VIDEO_BACKENDS = (
|
||||
'embed_video.backends.YoutubeBackend',
|
||||
'embed_video.backends.VimeoBackend',
|
||||
'embed_video.backends.SoundCloudBackend',
|
||||
'embed_video.tests.custom_backend.CustomBackend',
|
||||
)
|
||||
|
||||
|
||||
LOGGING = {
|
||||
'version': 1,
|
||||
'disable_existing_loggers': False,
|
||||
'handlers': {
|
||||
'console':{
|
||||
'level':'DEBUG',
|
||||
'class':'logging.StreamHandler',
|
||||
'console': {
|
||||
'level': 'DEBUG',
|
||||
'class': 'logging.StreamHandler',
|
||||
},
|
||||
},
|
||||
'loggers': {
|
||||
|
|
|
|||
|
|
@ -2,6 +2,3 @@ import os
|
|||
|
||||
os.environ['DJANGO_SETTINGS_MODULE'] = 'embed_video.tests.django_settings'
|
||||
|
||||
from .tests_fields import EmbedVideoFieldTestCase, EmbedVideoFormFieldTestCase
|
||||
from .tests_backend import EmbedVideoTestCase
|
||||
from .tests_tags import EmbedVideoNodeTestCase
|
||||
|
|
|
|||
25
embed_video/tests/tests_custom_backend.py
Normal file
25
embed_video/tests/tests_custom_backend.py
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
from unittest import TestCase
|
||||
|
||||
from embed_video.backends import detect_backend
|
||||
|
||||
from .custom_backend import CustomBackend
|
||||
|
||||
|
||||
class CustomBackendTestCase(TestCase):
|
||||
def setUp(self):
|
||||
self.backend = detect_backend('http://myvideo.com/1530')
|
||||
|
||||
def test_detect_backend(self):
|
||||
self.assertIsInstance(self.backend, CustomBackend)
|
||||
|
||||
def test_code(self):
|
||||
self.assertEqual(self.backend.code, '1530')
|
||||
|
||||
def test_url(self):
|
||||
self.assertEqual(self.backend.get_url(),
|
||||
'http://play.myvideo.com/c/1530/')
|
||||
|
||||
def test_thumbnail(self):
|
||||
self.assertEqual(self.backend.get_thumbnail_url(),
|
||||
'http://thumb.myvideo.com/c/1530/')
|
||||
|
||||
Loading…
Reference in a new issue