예제 #1
0
    def test_embedly_return_value(self):
        with patch('embedly.Embedly.oembed') as oembed:
            oembed.return_value = {'type': 'something else',
                                   'html': '<foo>bar</foo>'}
            result = wagtail_embedly('http://www.example.com', key='foo')
            self.assertEqual(result, {
                'title': '',
                'author_name': '',
                'provider_name': '',
                'type': 'something else',
                'thumbnail_url': None,
                'width': None,
                'height': None,
                'html': '<foo>bar</foo>'})

            oembed.return_value = {'type': 'something else',
                                   'author_name': 'Alice',
                                   'provider_name': 'Bob',
                                   'title': 'foo',
                                   'thumbnail_url': 'http://www.example.com',
                                   'width': 100,
                                   'height': 100,
                                   'html': '<foo>bar</foo>'}
            result = wagtail_embedly('http://www.example.com', key='foo')
            self.assertEqual(result, {'type': 'something else',
                                      'author_name': 'Alice',
                                      'provider_name': 'Bob',
                                      'title': 'foo',
                                      'thumbnail_url': 'http://www.example.com',
                                      'width': 100,
                                      'height': 100,
                                      'html': '<foo>bar</foo>'})
예제 #2
0
파일: tests.py 프로젝트: Gavryush/wagtail
    def test_embedly_return_value(self):
        with patch('embedly.Embedly.oembed') as oembed:
            oembed.return_value = {'type': 'something else',
                                   'html': '<foo>bar</foo>'}
            result = wagtail_embedly('http://www.example.com', key='foo')
            self.assertEqual(result, {
                'title': '',
                'author_name': '',
                'provider_name': '',
                'type': 'something else',
                'thumbnail_url': None,
                'width': None,
                'height': None,
                'html': '<foo>bar</foo>'})

            oembed.return_value = {'type': 'something else',
                                   'author_name': 'Alice',
                                   'provider_name': 'Bob',
                                   'title': 'foo',
                                   'thumbnail_url': 'http://www.example.com',
                                   'width': 100,
                                   'height': 100,
                                   'html': '<foo>bar</foo>'}
            result = wagtail_embedly('http://www.example.com', key='foo')
            self.assertEqual(result, {'type': 'something else',
                                      'author_name': 'Alice',
                                      'provider_name': 'Bob',
                                      'title': 'foo',
                                      'thumbnail_url': 'http://www.example.com',
                                      'width': 100,
                                      'height': 100,
                                      'html': '<foo>bar</foo>'})
예제 #3
0
    def test_embedly_oembed_called_with_correct_arguments(self):
        with patch("embedly.Embedly.oembed") as oembed:
            oembed.return_value = {"type": "photo", "url": "http://www.example.com"}

            wagtail_embedly("http://www.example.com", key="foo")
            oembed.assert_called_with("http://www.example.com", better=False)

            wagtail_embedly("http://www.example.com", max_width=100, key="foo")
            oembed.assert_called_with("http://www.example.com", maxwidth=100, better=False)
예제 #4
0
    def test_embedly_html_conversion(self):
        with patch("embedly.Embedly.oembed") as oembed:
            oembed.return_value = {"type": "photo", "url": "http://www.example.com"}
            result = wagtail_embedly("http://www.example.com", key="foo")
            self.assertEqual(result["html"], '<img src="http://www.example.com" />')

            oembed.return_value = {"type": "something else", "html": "<foo>bar</foo>"}
            result = wagtail_embedly("http://www.example.com", key="foo")
            self.assertEqual(result["html"], "<foo>bar</foo>")
예제 #5
0
파일: tests.py 프로젝트: Gavryush/wagtail
    def test_embedly_oembed_called_with_correct_arguments(self):
        with patch('embedly.Embedly.oembed') as oembed:
            oembed.return_value = {'type': 'photo',
                                   'url': 'http://www.example.com'}

            wagtail_embedly('http://www.example.com', key='foo')
            oembed.assert_called_with('http://www.example.com', better=False)

            wagtail_embedly('http://www.example.com', max_width=100, key='foo')
            oembed.assert_called_with('http://www.example.com', maxwidth=100, better=False)
예제 #6
0
    def test_embedly_oembed_called_with_correct_arguments(self):
        with patch('embedly.Embedly.oembed') as oembed:
            oembed.return_value = {'type': 'photo',
                                   'url': 'http://www.example.com'}

            wagtail_embedly('http://www.example.com', key='foo')
            oembed.assert_called_with('http://www.example.com', better=False)

            wagtail_embedly('http://www.example.com', max_width=100, key='foo')
            oembed.assert_called_with('http://www.example.com', maxwidth=100, better=False)
예제 #7
0
파일: tests.py 프로젝트: Gavryush/wagtail
    def test_embedly_html_conversion(self):
        with patch('embedly.Embedly.oembed') as oembed:
            oembed.return_value = {'type': 'photo',
                                   'url': 'http://www.example.com'}
            result = wagtail_embedly('http://www.example.com', key='foo')
            self.assertEqual(result['html'], '<img src="http://www.example.com" />')

            oembed.return_value = {'type': 'something else',
                                   'html': '<foo>bar</foo>'}
            result = wagtail_embedly('http://www.example.com', key='foo')
            self.assertEqual(result['html'], '<foo>bar</foo>')
예제 #8
0
    def test_embedly_html_conversion(self):
        with patch('embedly.Embedly.oembed') as oembed:
            oembed.return_value = {'type': 'photo',
                                   'url': 'http://www.example.com'}
            result = wagtail_embedly('http://www.example.com', key='foo')
            self.assertEqual(result['html'], '<img src="http://www.example.com" />')

            oembed.return_value = {'type': 'something else',
                                   'html': '<foo>bar</foo>'}
            result = wagtail_embedly('http://www.example.com', key='foo')
            self.assertEqual(result['html'], '<foo>bar</foo>')
예제 #9
0
    def test_embedly_return_value(self):
        with patch("embedly.Embedly.oembed") as oembed:
            oembed.return_value = {"type": "something else", "html": "<foo>bar</foo>"}
            result = wagtail_embedly("http://www.example.com", key="foo")
            self.assertEqual(
                result,
                {
                    "title": "",
                    "author_name": "",
                    "provider_name": "",
                    "type": "something else",
                    "thumbnail_url": None,
                    "width": None,
                    "height": None,
                    "html": "<foo>bar</foo>",
                },
            )

            oembed.return_value = {
                "type": "something else",
                "author_name": "Alice",
                "provider_name": "Bob",
                "title": "foo",
                "thumbnail_url": "http://www.example.com",
                "width": 100,
                "height": 100,
                "html": "<foo>bar</foo>",
            }
            result = wagtail_embedly("http://www.example.com", key="foo")
            self.assertEqual(
                result,
                {
                    "type": "something else",
                    "author_name": "Alice",
                    "provider_name": "Bob",
                    "title": "foo",
                    "thumbnail_url": "http://www.example.com",
                    "width": 100,
                    "height": 100,
                    "html": "<foo>bar</foo>",
                },
            )