当前位置: 首页>>代码示例>>Python>>正文


Python client.Embedly类代码示例

本文整理汇总了Python中embedly.client.Embedly的典型用法代码示例。如果您正苦于以下问题:Python Embedly类的具体用法?Python Embedly怎么用?Python Embedly使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Embedly类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_services_remains_empty_on_failed_http

    def test_services_remains_empty_on_failed_http(self, MockHttp):
        MockHttp.return_value.request.return_value = ({'status': 500}, "")

        client = Embedly(self.key)
        client.get_services()

        self.assertFalse(client.services)
        self.assertTrue(MockHttp.return_value.request.called)
开发者ID:TheAppCookbook,项目名称:Mystery-Box,代码行数:8,代码来源:tests.py

示例2: test_too_many_urls

    def test_too_many_urls(self):
        http = Embedly(self.key)

        urls = ['http://embed.ly'] * 21
        try:
            http.oembed(urls)
            self.fail('too many urls, should have thrown an error')
        except Exception as e:
            self.assertTrue(type(e), ValueError)
开发者ID:AlexeyKupershtokh,项目名称:embedly-python,代码行数:9,代码来源:tests.py

示例3: test_error

    def test_error(self):
        http = Embedly(self.key)

        obj = http.oembed('http://www.embedly.com/this/is/a/bad/url')
        self.assertTrue(obj['error'])
        obj = http.oembed('http://blog.embed.ly/lsbsdlfldsf/asdfkljlas/klajsdlfkasdf')
        self.assertTrue(obj['error'])
        obj = http.oembed('http://twitpic/nothing/to/see/here')
        self.assertTrue(obj['error'])
开发者ID:TheAppCookbook,项目名称:Mystery-Box,代码行数:9,代码来源:tests.py

示例4: test_error

 def test_error(self):
     http = Embedly(self.key)
     
     obj = http.oembed('http://www.youtube.com/this/is/a/bad/url')
     self.assert_(obj.error is True, obj.dict)
     obj = http.oembed('http://blog.embed.ly/lsbsdlfldsf/asdfkljlas/klajsdlfkasdf')
     self.assert_(obj.error is True, obj.dict)
     obj = http.oembed('http://twitpic/nothing/to/see/here')
     self.assert_(obj.error is True, obj.dict)
开发者ID:a85,项目名称:doublespeak,代码行数:9,代码来源:tests.py

示例5: test_raw_content_in_request

    def test_raw_content_in_request(self):
        client = Embedly(self.key)
        response = client.oembed(
            'http://www.scribd.com/doc/13994900/Easter',
            raw=True)

        self.assertEqual(response['raw'], response.data['raw'])

        parsed = json.loads(response['raw'].decode('utf-8'))
        self.assertEqual(response['type'], parsed['type'])
开发者ID:TheAppCookbook,项目名称:Mystery-Box,代码行数:10,代码来源:tests.py

示例6: set_embedly_data

 def set_embedly_data(self, field_name):
     original_field_value = getattr(self, 'original_{0}'.format(field_name))
     new_field_value = getattr(self, field_name)
     if new_field_value != original_field_value:
         embedly_key = getattr(settings, 'EMBEDLY_KEY')
         if embedly_key:
             client = Embedly(embedly_key)
             data_field_name = '{0}_data'.format(field_name)
             setattr(self, data_field_name, client.oembed(new_field_value)._data)
     setattr(self, 'original_{0}'.format(field_name), new_field_value)
开发者ID:guinslym,项目名称:moscowdjango,代码行数:10,代码来源:models.py

示例7: test_providers

 def test_providers(self):
     http = Embedly(self.key)
     
     objs = http.oembed(['http://www.scribd.com/doc/13994900/Easter',
                         'http://www.scribd.com/doc/28452730/Easter-Cards'])
     self.assert_(objs[0].provider_url == 'http://www.scribd.com/')
     self.assert_(objs[1].provider_url == 'http://www.scribd.com/')
     
     objs = http.oembed(['http://www.youtube.com/watch?v=Zk7dDekYej0',
                         'http://yfrog.com/h22eu4'])
     self.assert_(objs[0].provider_url == 'http://www.youtube.com/')
     self.assert_(objs[1].provider_url == 'http://yfrog.com/')
开发者ID:a85,项目名称:doublespeak,代码行数:12,代码来源:tests.py

示例8: test_provider

    def test_provider(self):
        http = Embedly(self.key)

        obj = http.oembed('http://www.scribd.com/doc/13994900/Easter')
        self.assertTrue(obj.provider_url == 'http://www.scribd.com/')

        obj = http.oembed('http://www.scribd.com/doc/28452730/Easter-Cards')
        self.assertTrue(obj.provider_url == 'http://www.scribd.com/')

        obj = http.oembed('http://www.youtube.com/watch?v=Zk7dDekYej0')
        self.assertTrue(obj.provider_url == 'http://www.youtube.com/')

        obj = http.oembed('http://yfrog.com/h22eu4j')
        self.assertTrue(obj.provider_url == 'http://yfrog.com')
开发者ID:AlexeyKupershtokh,项目名称:embedly-python,代码行数:14,代码来源:tests.py

示例9: test_provider

    def test_provider(self):
        http = Embedly(self.key)

        obj = http.oembed("http://www.scribd.com/doc/13994900/Easter")
        self.assert_(obj.provider_url == "http://www.scribd.com/")

        obj = http.oembed("http://www.scribd.com/doc/28452730/Easter-Cards")
        self.assert_(obj.provider_url == "http://www.scribd.com/")

        obj = http.oembed("http://www.youtube.com/watch?v=Zk7dDekYej0")
        self.assert_(obj.provider_url == "http://www.youtube.com/")

        obj = http.oembed("http://yfrog.com/h22eu4j")
        self.assert_(obj.provider_url == "http://yfrog.com")
开发者ID:nabilt,项目名称:Like-List,代码行数:14,代码来源:tests.py

示例10: test_multi_errors

    def test_multi_errors(self):
        http = Embedly(self.key)

        objs = http.oembed(["http://www.youtube.com/this/is/a/bad/url", "http://blog.embed.ly/alsd/slsdlf/asdlfj"])
        self.assert_(objs[0].type == "error", objs[0].dict)
        self.assert_(objs[1].type == "error", objs[1].dict)

        objs = http.oembed(["http://blog.embed.ly/lsbsdlfldsf/asdf/kl", "http://twitpic.com/nothing/to/see/here"])
        self.assert_(objs[0].type == "error", objs[0].dict)
        self.assert_(objs[1].type == "error", objs[1].dict)

        objs = http.oembed(["http://blog.embed.ly/lsbsdlfldsf/asdf/kl", "http://yfrog.com/h22eu4j"])
        self.assert_(objs[0].type == "error", objs[0].dict)
        self.assert_(objs[1].type == "photo", objs[1].dict)

        objs = http.oembed(["http://yfrog.com/h22eu4j", "http://www.scribd.com/asdf/asdf/asdfasdf"])
        self.assert_(objs[0].type == "photo", objs[0].dict)
        self.assert_(objs[1].type == "error", objs[1].dict)
开发者ID:nabilt,项目名称:Like-List,代码行数:18,代码来源:tests.py

示例11: test_multi_errors

    def test_multi_errors(self):
        http = Embedly(self.key)

        objs = list(http.oembed(['http://www.embedly.com/this/is/a/bad/url',
                                 'http://blog.embed.ly/alsd/slsdlf/asdlfj']))
        self.assertTrue(objs[0].type == 'error', objs[0].dict)
        self.assertTrue(objs[1].type == 'error', objs[1].dict)

        objs = list(http.oembed(['http://blog.embed.ly/lsbsdlfldsf/asdf/kl',
                                 'http://twitpic.com/nothing/to/see/here']))
        self.assertTrue(objs[0].type == 'error',objs[0].dict)
        self.assertTrue(objs[1].type == 'error',objs[1].dict)

        objs = list(http.oembed(['http://blog.embed.ly/lsbsdlfldsf/asdf/kl',
                                 'http://yfrog.com/h22eu4j']))
        self.assertTrue(objs[0].type == 'error',objs[0].dict)
        self.assertTrue(objs[1].type == 'photo',objs[1].dict)

        objs = list(http.oembed(['http://yfrog.com/h22eu4j',
                                 'http://www.scribd.com/asdf/asdf/asdfasdf']))
        self.assertTrue(objs[0].type == 'photo',objs[0].dict)
        self.assertTrue(objs[1].type == 'error',objs[1].dict)
开发者ID:AlexeyKupershtokh,项目名称:embedly-python,代码行数:22,代码来源:tests.py

示例12: test_regex_url_matches

    def test_regex_url_matches(self):
        regex = [
            'http://.*youtube\\.com/watch.*',
            'http://www\\.vimeo\\.com/.*']
        client = Embedly(self.key)
        client._regex = re.compile('|'.join(regex))

        self.assertTrue(
            client.is_supported('http://www.youtube.com/watch?v=Zk7dDekYej0'))
        self.assertTrue(
            client.is_supported('http://www.vimeo.com/18150336'))
        self.assertFalse(
            client.is_supported('http://vimeo.com/18150336'))
        self.assertFalse(
            client.is_supported('http://yfrog.com/h22eu4j'))
开发者ID:TheAppCookbook,项目名称:Mystery-Box,代码行数:15,代码来源:tests.py

示例13: test_services_can_be_manually_configured

    def test_services_can_be_manually_configured(self):
        client = Embedly(self.key)
        client.services = ['nothing', 'like', 'real', 'response', 'data']

        self.assertTrue('nothing' in client.get_services())
        self.assertEqual(len(client.get_services()), 5)
开发者ID:TheAppCookbook,项目名称:Mystery-Box,代码行数:6,代码来源:tests.py

示例14: test_exception_on_too_many_urls

    def test_exception_on_too_many_urls(self):
        http = Embedly(self.key)
        urls = ['http://embed.ly'] * 21

        with self.assertRaises(ValueError):
            http.oembed(urls)
开发者ID:se3000,项目名称:embedly-python,代码行数:6,代码来源:tests.py

示例15: test_objectify

    def test_objectify(self):
        client = Embedly(self.key)
        response = client.objectify('http://vimeo.com/18150336')

        self.assertEqual(response.method, 'objectify')
        self.assertEqual(response['provider_name'], 'Vimeo')
开发者ID:TheAppCookbook,项目名称:Mystery-Box,代码行数:6,代码来源:tests.py


注:本文中的embedly.client.Embedly类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。