def test_video_field_to_xml(self): from wechatpy.fields import VideoField value = {"media_id": "123456", "title": "test", "description": "test"} expected = f"""<Video> <MediaId><![CDATA[{value["media_id"]}]]></MediaId> <Title><![CDATA[{value["title"]}]]></Title> <Description><![CDATA[{value["description"]}]]></Description> </Video>""" field = VideoField("Video") self.assertXMLEqual(expected, field.to_xml(value))
def test_video_field_to_xml(self): from wechatpy.fields import VideoField value = {'media_id': '123456', 'title': 'test', 'description': 'test'} expected = """<Video> <MediaId><![CDATA[{media_id}]]></MediaId> <Title><![CDATA[{title}]]></Title> <Description><![CDATA[{description}]]></Description> </Video>""".format(media_id=value['media_id'], title=value['title'], description=value['description']) field = VideoField('Video') self.assertXMLEqual(expected, field.to_xml(value))
def test_video_field_to_xml(self): from wechatpy.fields import VideoField value = {"media_id": "123456", "title": "test", "description": "test"} expected = """<Video> <MediaId><![CDATA[{media_id}]]></MediaId> <Title><![CDATA[{title}]]></Title> <Description><![CDATA[{description}]]></Description> </Video>""".format( media_id=value["media_id"], title=value["title"], description=value["description"] ) field = VideoField("Video") self.assertEqual(expected, field.to_xml(value))
def test_video_field_to_xml(self): from wechatpy.fields import VideoField value = { 'media_id': '123456', 'title': 'test', 'description': 'test' } expected = """<Video> <MediaId><![CDATA[{media_id}]]></MediaId> <Title><![CDATA[{title}]]></Title> <Description><![CDATA[{description}]]></Description> </Video>""".format( media_id=value['media_id'], title=value['title'], description=value['description'] ) field = VideoField('Video') self.assertEqual(expected, field.to_xml(value))
class VideoReply(BaseReply): """ 视频回复 详情请参阅 https://developers.weixin.qq.com/doc/offiaccount/Message_Management/Passive_user_reply_message.html """ type = "video" video = VideoField("Video", {}) @property def media_id(self): return self.video.get("media_id") @media_id.setter def media_id(self, value): video = self.video video["media_id"] = value self.video = video @property def title(self): return self.video.get("title") @title.setter def title(self, value): video = self.video video["title"] = value self.video = video @property def description(self): return self.video.get("description") @description.setter def description(self, value): video = self.video video["description"] = value self.video = video
class VideoReply(BaseReply): """ 视频回复 详情请参阅 http://mp.weixin.qq.com/wiki/9/2c15b20a16019ae613d413e30cac8ea1.html """ type = 'video' video = VideoField('Video', {}) @property def media_id(self): return self.video.get('media_id') @media_id.setter def media_id(self, value): video = self.video video['media_id'] = value self.video = video @property def title(self): return self.video.get('title') @title.setter def title(self, value): video = self.video video['title'] = value self.video = video @property def description(self): return self.video.get('description') @description.setter def description(self, value): video = self.video video['description'] = value self.video = video