本文整理汇总了Python中models.Album.parse方法的典型用法代码示例。如果您正苦于以下问题:Python Album.parse方法的具体用法?Python Album.parse怎么用?Python Album.parse使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Album
的用法示例。
在下文中一共展示了Album.parse方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_parse_album
# 需要导入模块: from models import Album [as 别名]
# 或者: from models.Album import parse [as 别名]
def test_parse_album(self):
response = '''{"response":[{"aid":"16178407","thumb_id":"96509883","owner_id":"6492","title":"qwerty",
"description":"desc","created":"1298365200","updated":"1298365201","size":"3",
"privacy":"3"},{"aid":"17071606","thumb_id":"98054577","owner_id":"-6492",
"title":"","description":"","created":"1204576880","updated":"1229532461",
"size":"3","privacy":"0"}]}
'''
instance = Album()
owner = UserFactory.create(remote_id=6492)
instance.parse(json.loads(response)['response'][0])
instance.save()
self.assertEqual(instance.remote_id, '6492_16178407')
self.assertEqual(instance.thumb_id, 96509883)
self.assertEqual(instance.owner, owner)
self.assertEqual(instance.title, 'qwerty')
self.assertEqual(instance.description, 'desc')
self.assertEqual(instance.created, datetime(2011,2,22,9,0,0))
self.assertEqual(instance.updated, datetime(2011,2,22,9,0,1))
self.assertEqual(instance.size, 3)
self.assertEqual(instance.privacy, 3)
instance = Album()
group = GroupFactory.create(remote_id=6492)
instance.parse(json.loads(response)['response'][1])
instance.save()
self.assertEqual(instance.remote_id, '-6492_17071606')
self.assertEqual(instance.group, group)
示例2: test_parse_album
# 需要导入模块: from models import Album [as 别名]
# 或者: from models.Album import parse [as 别名]
def test_parse_album(self):
owner = GroupFactory(remote_id=GROUP_ID)
d = {u'count': 16, u'photo_320': u'http://cs619722.vk.me/u8704019/video/l_6369beb6.jpg', u'title': u'Coca-Cola Football',
u'photo_160': u'http://cs619722.vk.me/u8704019/video/m_ef3493e1.jpg', u'id': 54387280, u'owner_id': -16297716}
instance = Album()
instance.parse(d)
instance.save()
self.assertEqual(instance.owner, owner)
self.assertEqual(instance.pk, d['id'])
self.assertEqual(instance.title, d['title'])
self.assertEqual(instance.videos_count, 16)
self.assertEqual(instance.photo_160, d['photo_160'])