예제 #1
0
    def testEmbedly(self, urllib_mock):
        blip = Embedly('https://vine.co/v/eHHOtXV5lxT', (600, 400))
        embed = '<iframe class="embedly-embed" src="//cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fvine.co%2Fv%2FeHHOtXV5lxT%2Fembed%2Fsimple&url=https%3A%2F%2Fvine.co%2Fv%2FeHHOtXV5lxT&image=https%3A%2F%2Fv.cdn.vine.co%2Fr%2Fvideos%2FB3FA3B51771240096733128749056_39a5c18c0e0.2.1.15446276152990570361.mp4.jpg%3FversionId%3DnM.tB7FoIhn4z059SNsYgmz.2RmLKV4x&key=6d7c04d32bab45e8b7d7e2ad09d10917&type=text%2Fhtml&schema=vine" width="500" height="500" scrolling="no" frameborder="0" allowfullscreen></iframe>'
        thumbnail = 'https://v.cdn.vine.co/r/videos/B3FA3B51771240096733128749056_39a5c18c0e0.2.1.15446276152990570361.mp4.jpg?versionId=nM.tB7FoIhn4z059SNsYgmz.2RmLKV4x'

        with patch('magicembed.providers.Embedly._call_api', MagicMock()):
            self.assertNotEqual(blip.render_video(), embed)

        api_call_mock = MagicMock(return_value={"thumbnail_url": thumbnail})
        with patch('magicembed.providers.json.loads', api_call_mock):
            self.assertEqual(blip.render_thumbnail(), thumbnail)
예제 #2
0
    def testEmbedly(self, urllib_mock):
        blip = Embedly('https://vine.co/v/eHHOtXV5lxT', (600, 400))
        embed = '<iframe class="embedly-embed" src="//cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fvine.co%2Fv%2FeHHOtXV5lxT%2Fembed%2Fsimple&url=https%3A%2F%2Fvine.co%2Fv%2FeHHOtXV5lxT&image=https%3A%2F%2Fv.cdn.vine.co%2Fr%2Fvideos%2FB3FA3B51771240096733128749056_39a5c18c0e0.2.1.15446276152990570361.mp4.jpg%3FversionId%3DnM.tB7FoIhn4z059SNsYgmz.2RmLKV4x&key=6d7c04d32bab45e8b7d7e2ad09d10917&type=text%2Fhtml&schema=vine" width="500" height="500" scrolling="no" frameborder="0" allowfullscreen></iframe>'
        thumbnail = 'https://v.cdn.vine.co/r/videos/B3FA3B51771240096733128749056_39a5c18c0e0.2.1.15446276152990570361.mp4.jpg?versionId=nM.tB7FoIhn4z059SNsYgmz.2RmLKV4x'

        with patch('magicembed.providers.Embedly._call_api', MagicMock()):
            self.assertNotEqual(blip.render_video(), embed)

        api_call_mock = MagicMock(
            return_value={
                "thumbnail_url": thumbnail
            }
        )
        with patch('magicembed.providers.json.loads', api_call_mock):
            self.assertEqual(blip.render_thumbnail(), thumbnail)
예제 #3
0
    def test_call_Embedly_api_without_key(self):
        blip = Embedly('https://vine.co/v/eHHOtXV5lxT', (600, 400))

        with self.settings(EMBEDLY_KEY=None):
            with self.assertRaises(ImproperlyConfigured):
                blip.render_thumbnail()
예제 #4
0
    def test_call_Embedly_api_without_key(self):
        blip = Embedly('https://vine.co/v/eHHOtXV5lxT', (600, 400))

        with self.settings(EMBEDLY_KEY=None):
            with self.assertRaises(ImproperlyConfigured):
                blip.render_thumbnail()