MCPcopy
hub / github.com/wechatpy/wechatpy / test_article_field_to_xml

Method test_article_field_to_xml

tests/test_fields.py:126–155  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

124 self.assertXMLEqual(expected, field.to_xml(value))
125
126 def test_article_field_to_xml(self):
127 from wechatpy.fields import ArticlesField
128
129 articles = [
130 {
131 'title': 'test 1',
132 'description': 'test 1',
133 'image': 'http://www.qq.com/1.png',
134 'url': 'http://www.qq.com/1'
135 },
136 {
137 'title': 'test 2',
138 'description': 'test 2',
139 'image': 'http://www.qq.com/2.png',
140 'url': 'http://www.qq.com/2'
141 },
142 {
143 'title': 'test 3',
144 'description': 'test 3',
145 'image': 'http://www.qq.com/3.png',
146 'url': 'http://www.qq.com/3'
147 },
148 ]
149 article_count = len(articles)
150
151 field = ArticlesField('Article')
152 expected = '<ArticleCount>{article_count}</ArticleCount>'.format(
153 article_count=article_count
154 )
155 assert expected in field.to_xml(articles)
156
157 def test_base64encode_field_to_xml(self):
158 from wechatpy.fields import Base64EncodeField

Callers

nothing calls this directly

Calls 2

to_xmlMethod · 0.95
ArticlesFieldClass · 0.90

Tested by

no test coverage detected