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


Python Image.url方法代码示例

本文整理汇总了Python中app.models.Image.url方法的典型用法代码示例。如果您正苦于以下问题:Python Image.url方法的具体用法?Python Image.url怎么用?Python Image.url使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在app.models.Image的用法示例。


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

示例1: test_create_image

# 需要导入模块: from app.models import Image [as 别名]
# 或者: from app.models.Image import url [as 别名]
    def test_create_image(self):
        image = Image()
        image.height = 640
        image.width = 640
        image.url = 'http://scontent-b.cdninstagram.com/hphotos-xpa1/t51.2885-15/10522310_677385995673625_267718762_n.jpg'
        image.type = 'standard_resolution'

        db.session.add(image)
        db.session.commit()

        self.assertIn(image, db.session)
开发者ID:johncadengo,项目名称:willchoi.me,代码行数:13,代码来源:test_models.py

示例2: test_create_photo

# 需要导入模块: from app.models import Image [as 别名]
# 或者: from app.models.Image import url [as 别名]
    def test_create_photo(self):
        # Start with photo
        photo = Photo()
        photo.instagram_id = '757677846642235453_1134805'
        photo.caption = '126. Who needs fireworks anyway'
        photo.created_time = datetime(2012, 02, 29)
        photo.featured_on = 'Josh Johnson; #JJ'
        photo.link = 'http://instagram.com/p/qDVDHkyxvS/'

        db.session.add(photo)
        db.session.commit()

        self.assertIn(photo, db.session)

        # Mock some images
        hi_img = Image()
        hi_img.height = 640
        hi_img.width = 640
        hi_img.url = 'http://scontent-b.cdninstagram.com/hphotos-xpa1/t51.2885-15/10522310_677385995673625_267718762_n.jpg'
        hi_img.type = 'standard_resolution'

        low_img = Image()
        low_img.height = 306
        low_img.width = 306
        low_img.url = 'http://scontent-b.cdninstagram.com/hphotos-xpa1/t51.2885-15/10522310_677385995673625_267718762_a.jpg'
        low_img.type = 'low_resolution'

        thumb_img = Image()
        thumb_img.height = 150
        thumb_img.width = 150
        thumb_img.url = 'http://scontent-b.cdninstagram.com/hphotos-xpa1/t51.2885-15/10522310_677385995673625_267718762_s.jpg'
        thumb_img.type = 'thumbnail'

        images = [hi_img, low_img, thumb_img]
        db.session.add_all(images)
        db.session.commit()

        self.assertTrue(all(i in db.session for i in images))

        # Connect images to photo
        photo.images.extend(images)
        db.session.commit()

        self.assertTrue(all(i in photo.images for i in images))
        self.assertTrue(all(photo is i.photo for i in images))

        # Mock location and tag
        loc = Location()
        loc.instagram_id = '1'
        loc.name = 'Dogpatch Labs'
        loc.latitude = 37.782
        loc.longitude = -122.387

        db.session.add(loc)
        db.session.commit()

        self.assertIn(loc, db.session)

        tag = Tag()
        tag.name = 'july4th'

        db.session.add(tag)
        db.session.commit()

        self.assertIn(tag, db.session)

        # Connect location and tag to photo
        photo.locations.append(loc)
        photo.tags.append(tag)

        db.session.commit()

        self.assertIn(loc, photo.locations)
        self.assertIn(tag, photo.tags)
        self.assertIn(photo, loc.photos)
        self.assertIn(photo, tag.photos)
开发者ID:johncadengo,项目名称:willchoi.me,代码行数:78,代码来源:test_models.py


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