How to use wechatpy - 10 common examples

To help you get started, we’ve selected a few wechatpy examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github jxtech / wechatpy / tests / test_session.py View on Github external
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))
github jxtech / wechatpy / tests / test_session.py View on Github external
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)
github jxtech / wechatpy / tests / test_fields.py View on Github external
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))
github jxtech / wechatpy / tests / test_parser.py View on Github external
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)
github jxtech / wechatpy / tests / test_parser.py View on Github external
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)
github jxtech / wechatpy / tests / test_parser.py View on Github external
def test_parse_link_message(self):
        xml = """
        
        
        1351776360
        
        <title>&lt;![CDATA[公众平台官网链接]]&gt;</title>
        
        
        1234567890123456
        """

        msg = parse_message(xml)
        self.assertEqual('link', msg.type)
github jxtech / wechatpy / tests / test_parser.py View on Github external
1475134700
        
        
        <title>&lt;![CDATA[样例公司抬头]]&gt;</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)
github jxtech / wechatpy / tests / test_events.py View on Github external
1408090816
        
        
        
        1
        
        
        
        
        
        
        """

        event = parse_message(xml)

        self.assertTrue(isinstance(event, PicPhotoOrAlbumEvent))
        self.assertEqual(1, event.count)
        self.assertEqual(
            '5a75aaca956d97be686719218f275c6b',
            event.pictures[0]['PicMd5Sum']
        )
github jxtech / wechatpy / tests / test_events.py View on Github external
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)
github jxtech / wechatpy / tests / test_parser.py View on Github external
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)