本文整理汇总了Python中lassie.Lassie类的典型用法代码示例。如果您正苦于以下问题:Python Lassie类的具体用法?Python Lassie怎么用?Python Lassie使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Lassie类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_str_image
def test_str_image(self):
url = 'http://lassie.it/amp/str_image.html'
l = Lassie()
data = l.fetch(url)
self.assertEqual(1, len(data['images']))
示例2: test_bad_json
def test_bad_json(self):
url = 'http://lassie.it/amp/bad_json.html'
l = Lassie()
data = l.fetch(url)
self.assertTrue('amp' in data['url'])
示例3: test_list_json
def test_list_json(self):
url = 'http://lassie.it/amp/list_json.html'
l = Lassie()
data = l.fetch(url)
self.assertTrue('Pixar' in data['description'])
示例4: test_list_image_empty
def test_list_image_empty(self):
url = 'http://lassie.it/amp/list_image_empty.html'
l = Lassie()
data = l.fetch(url)
self.assertEqual(1, len(data['images']))
示例5: test_list_thumbnail_image
def test_list_thumbnail_image(self):
url = 'http://lassie.it/amp/list_thumbnail_image.html'
l = Lassie()
data = l.fetch(url)
self.assertEqual(2, len(data['images']))
示例6: test_video_objects
def test_video_objects(self):
url = 'http://lassie.it/amp/video_objects.html'
l = Lassie()
data = l.fetch(url)
self.assertEqual(1, len(data['videos']))
示例7: test_no_html_tag
def test_no_html_tag(self):
url = 'http://lassie.it/core/no_html_tag.html'
l = Lassie()
data = l.fetch(url)
self.assertTrue('no_html_tag' in data['title'])
示例8: test_bad_url
def test_bad_url(self):
url = 'http://lassie.it/youtube/bad_url_123456.json'
l = Lassie()
data = l.fetch(url)
self.assertIsNone(data.get('oembed'))
示例9: test_merge_request_kwargs
def test_merge_request_kwargs(self):
l = Lassie()
l.request_opts = {
'timeout': 3,
}
request_kwargs = l.merge_request_kwargs()
self.assertTrue('timeout' in request_kwargs)
示例10: test_request_opts_default_user_agent
def test_request_opts_default_user_agent(self):
l = Lassie()
l.request_opts = {
'timeout': 3
}
# headers should be set to {} then User-Agent should be added
self.assertTrue(l.client.headers['User-Agent'] == FAKE_USER_AGENT)
示例11: test_youtube_good
def test_youtube_good(self):
url = 'http://lassie.it/youtube/good.json'
l = Lassie()
data = l.fetch(url)
self.assertEqual(len(data['videos']), 1)
self.assertEqual(len(data['images']), 1)
示例12: test_core_class_setting_is_none
def test_core_class_setting_is_none(self):
url = "http://lassie.it/core/class_setting_is_none.html"
# This is a really odd use-case where they'd set the class attr to None, but it might happen so oh wellz.
l = Lassie()
l.open_graph = None
data = l.fetch(url, open_graph=False)
self.assertEqual(len(data["images"]), 0)
示例13: test_request_opts_no_headers
def test_request_opts_no_headers(self):
l = Lassie()
l.request_opts = {
'headers': {},
'timeout': 3
}
# headers should be set to {} then User-Agent should be added
self.assertTrue(l.client.headers != {})
示例14: test_all_properites
def test_all_properites(self):
url = 'http://lassie.it/amp/all_properties.html'
l = Lassie()
data = l.fetch(url, all_images=True)
self.assertEqual(len(data['images']), 3)
title = 'Google Glass Is Dead, Long Live Snapchat Spectacles'
self.assertEqual(data['title'], title)
示例15: test_bad_image_dimensions
def test_bad_image_dimensions(self):
url = "http://lassie.it/core/bad_image_dimensions.html"
l = Lassie()
data = l.fetch(url, all_images=True)
# lassie.utils.convert_to_int will except a TypeError or ValueError and pass (not setting a width/height on the image)
image = data["images"][0]
self.assertTrue(not "width" in image)
self.assertTrue(not "height" in image)