Ejemplo n.º 1
0
    def test_music_field_to_xml(self):
        from wechatpy.fields import MusicField

        value = {
            'thumb_media_id': '123456',
            'title': 'test',
            'description': 'test',
            'music_url': '',
            'hq_music_url': ''
        }
        expected = """<Music>
        <ThumbMediaId><![CDATA[{thumb_media_id}]]></ThumbMediaId>
        <Title><![CDATA[{title}]]></Title>
        <Description><![CDATA[{description}]]></Description>
        <MusicUrl><![CDATA[{music_url}]]></MusicUrl>
        <HQMusicUrl><![CDATA[{hq_music_url}]]></HQMusicUrl>
        </Music>""".format(
            thumb_media_id=value['thumb_media_id'],
            title=value['title'],
            description=value['description'],
            music_url=value['music_url'],
            hq_music_url=value['hq_music_url']
        )

        field = MusicField('Music')
        self.assertEqual(expected, field.to_xml(value))
Ejemplo n.º 2
0
    def test_music_field_to_xml(self):
        from wechatpy.fields import MusicField

        value = {
            "thumb_media_id": "123456",
            "title": "test",
            "description": "test",
            "music_url": "",
            "hq_music_url": "",
        }
        expected = """<Music>
        <ThumbMediaId><![CDATA[{thumb_media_id}]]></ThumbMediaId>
        <Title><![CDATA[{title}]]></Title>
        <Description><![CDATA[{description}]]></Description>
        <MusicUrl><![CDATA[{music_url}]]></MusicUrl>
        <HQMusicUrl><![CDATA[{hq_music_url}]]></HQMusicUrl>
        </Music>""".format(
            thumb_media_id=value["thumb_media_id"],
            title=value["title"],
            description=value["description"],
            music_url=value["music_url"],
            hq_music_url=value["hq_music_url"],
        )

        field = MusicField("Music")
        self.assertEqual(expected, field.to_xml(value))
Ejemplo n.º 3
0
    def test_music_field_to_xml(self):
        from wechatpy.fields import MusicField

        value = {
            "thumb_media_id": "123456",
            "title": "test",
            "description": "test",
            "music_url": "",
            "hq_music_url": "",
        }
        expected = """<Music>
        <ThumbMediaId><![CDATA[{thumb_media_id}]]></ThumbMediaId>
        <Title><![CDATA[{title}]]></Title>
        <Description><![CDATA[{description}]]></Description>
        <MusicUrl><![CDATA[{music_url}]]></MusicUrl>
        <HQMusicUrl><![CDATA[{hq_music_url}]]></HQMusicUrl>
        </Music>""".format(
            thumb_media_id=value["thumb_media_id"],
            title=value["title"],
            description=value["description"],
            music_url=value["music_url"],
            hq_music_url=value["hq_music_url"],
        )

        field = MusicField("Music")
        self.assertXMLEqual(expected, field.to_xml(value))