當前位置: 首頁>>代碼示例>>Python>>正文


Python Album.parse方法代碼示例

本文整理匯總了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)
開發者ID:wd5,項目名稱:1-django-vkontakte-photos,代碼行數:32,代碼來源:tests.py

示例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'])
開發者ID:Andertaker,項目名稱:django-vkontakte-video,代碼行數:19,代碼來源:tests.py


注:本文中的models.Album.parse方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。