Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_memory_session_storage_init(self):
from wechatpy.session.memorystorage import MemoryStorage
client = WeChatClient(self.app_id, self.secret)
self.assertTrue(isinstance(client.session, MemoryStorage))
def test_shove_storage_init(self):
from wechatpy.session.shovestorage import ShoveStorage
uri = 'memory://'
client = WeChatClient(self.app_id, self.secret, session=uri)
self.assertTrue(isinstance(client.session, ShoveStorage))
self.assertEqual('wechatpy', client.session.prefix)
def test_string_field_to_xml(self):
from wechatpy.fields import StringField
name = 'Content'
value = 'test'
expected = '<{name}>'.format(
name=name,
value=value
)
field = StringField(name)
self.assertEqual(expected, field.to_xml(value))
def test_parse_click_event(self):
xml = """
123456789
"""
msg = parse_message(xml)
self.assertEqual('event', msg.type)
self.assertEqual('click', msg.event)
self.assertEqual('EVENTKEY', msg.key)
def test_parse_location_message(self):
xml = """
1351776360
23.134521
113.358803
20
<label></label>
1234567890123456
"""
msg = parse_message(xml)
self.assertEqual('location', msg.type)
def test_parse_link_message(self):
xml = """
1351776360
<title><![CDATA[公众平台官网链接]]></title>
1234567890123456
"""
msg = parse_message(xml)
self.assertEqual('link', msg.type)
1475134700
<title><![CDATA[样例公司抬头]]></title>
"""
msg = parse_message(xml)
self.assertTrue(isinstance(msg, SubmitInvoiceTitleEvent))
self.assertEqual('样例公司抬头', msg.title)
self.assertEqual('1486715661', msg.tax_no)
self.assertEqual('abc', msg.addr)
self.assertEqual('13313331333', msg.phone)
self.assertEqual('bt', msg.bank_type)
self.assertEqual('bn', msg.bank_no)
self.assertEqual('at', msg.attach)
self.assertEqual('InvoiceUserTitleBusinessType', msg.title_type)
1408090816
1
"""
event = parse_message(xml)
self.assertTrue(isinstance(event, PicPhotoOrAlbumEvent))
self.assertEqual(1, event.count)
self.assertEqual(
'5a75aaca956d97be686719218f275c6b',
event.pictures[0]['PicMd5Sum']
)
def test_kf_switch_session_event(self):
from wechatpy.events import KfSwitchSessionEvent
xml = """
1399197672
"""
event = parse_message(xml)
self.assertTrue(isinstance(event, KfSwitchSessionEvent))
self.assertEqual('test1@test', event.from_account)
self.assertEqual('test2@test', event.to_account)
def test_parse_scan_event(self):
xml = """
123456789
"""
msg = parse_message(xml)
self.assertEqual('event', msg.type)
self.assertEqual('scan', msg.event)
self.assertEqual('123123', msg.scene_id)
self.assertEqual('TICKET', msg.ticket)