# -*- coding: utf-8 -*- import re import unittest import markdown from mock import patch from nose.plugins.skip import SkipTest from mdx_oembed.extension import OEMBED_LINK_RE from mdx_oembed import endpoints class OEmbedPatternRegexTestCase(unittest.TestCase): def setUp(self): self.re = re.compile(OEMBED_LINK_RE) def test_ignore_relative_image_link(self): text = '' match = self.re.match(text) self.assertIsNone(match) def test_ignore_absolute_image_link(self): text = '' match = self.re.match(text) self.assertIsNone(match) def test_ignore_png_image_link(self): text = '' match = self.re.match(text) self.assertIsNone(match) def test_ignore_jpg_image_link(self): text = '' match = self.re.match(text) self.assertIsNone(match) def test_ignore_gif_image_link(self): text = '' match = self.re.match(text) self.assertIsNone(match) def test_find_youtube_link(self): text = '' match = self.re.match(text) self.assertIsNotNone(match) def test_find_youtube_short_link(self): text = '' match = self.re.match(text) self.assertIsNotNone(match) def test_find_youtube_http(self): text = '' match = self.re.match(text) self.assertIsNotNone(match) def test_find_youtube_https(self): text = '' match = self.re.match(text) self.assertIsNotNone(match) def test_find_youtube_auto(self): text = '' match = self.re.match(text) self.assertIsNotNone(match) class OEmbedExtensionTestCase(unittest.TestCase): def setUp(self): self.markdown = markdown.Markdown(extensions=['oembed']) def assert_convert(self, text, expected): with patch('oembed.OEmbedEndpoint') as MockOEmbedEndpoint: MockOEmbedEndpoint.get.return_value = expected output = self.markdown.convert(text) self.assertEqual(output, expected) class IgnoredTestCase(OEmbedExtensionTestCase): """ The OEmbedExtension should ignore these tags allowing markdown's image processor to find and handle them. """ def test_relative(self): text = '' expected = '


