当前位置: 首页>>代码示例>>Python>>正文


Python httmock.HTTMock方法代码示例

本文整理汇总了Python中httmock.HTTMock方法的典型用法代码示例。如果您正苦于以下问题:Python httmock.HTTMock方法的具体用法?Python httmock.HTTMock怎么用?Python httmock.HTTMock使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在httmock的用法示例。


在下文中一共展示了httmock.HTTMock方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_external_contact_send_welcome_msg

# 需要导入模块: import httmock [as 别名]
# 或者: from httmock import HTTMock [as 别名]
def test_external_contact_send_welcome_msg(self):
        with HTTMock(wechat_api_mock):
            res = self.client.external_contact.send_welcome_msg(
                {
                    "welcome_code": "CALLBACK_CODE",
                    "text": {"content": "文本消息内容"},
                    "image": {"media_id": "MEDIA_ID"},
                    "link": {
                        "title": "消息标题",
                        "picurl": "https://example.pic.com/path",
                        "desc": "消息描述",
                        "url": "https://example.link.com/path",
                    },
                    "miniprogram": {
                        "title": "消息标题",
                        "pic_media_id": "MEDIA_ID",
                        "appid": "wx8bd80126147df384",
                        "page": "/path/index",
                    },
                }
            )
            self.assertEqual(0, res["errcode"]) 
开发者ID:wechatpy,项目名称:wechatpy,代码行数:24,代码来源:test_work_client.py

示例2: test_memcached_storage_access_token

# 需要导入模块: import httmock [as 别名]
# 或者: from httmock import HTTMock [as 别名]
def test_memcached_storage_access_token(self):
        if platform.system() == "Windows":
            return

        from pymemcache.client import Client
        from wechatpy.session.memcachedstorage import MemcachedStorage

        servers = ("127.0.0.1", 11211)
        memcached = Client(servers)
        session = MemcachedStorage(memcached)
        client = WeChatClient(self.app_id, self.secret, session=session)
        with HTTMock(wechat_api_mock):
            token = client.fetch_access_token()
            self.assertEqual("1234567890", token["access_token"])
            self.assertEqual(7200, token["expires_in"])
            self.assertEqual("1234567890", client.access_token) 
开发者ID:wechatpy,项目名称:wechatpy,代码行数:18,代码来源:test_session.py

示例3: test_fetch_access_token

# 需要导入模块: import httmock [as 别名]
# 或者: from httmock import HTTMock [as 别名]
def test_fetch_access_token(self):
        with HTTMock(wechat_api_mock):
            res = self.oauth.fetch_access_token("123456")
            self.assertEqual("ACCESS_TOKEN", res["access_token"]) 
开发者ID:wechatpy,项目名称:wechatpy,代码行数:6,代码来源:test_oauth.py

示例4: test_refresh_access_token

# 需要导入模块: import httmock [as 别名]
# 或者: from httmock import HTTMock [as 别名]
def test_refresh_access_token(self):
        with HTTMock(wechat_api_mock):
            res = self.oauth.refresh_access_token("123456")
            self.assertEqual("ACCESS_TOKEN", res["access_token"]) 
开发者ID:wechatpy,项目名称:wechatpy,代码行数:6,代码来源:test_oauth.py

示例5: test_get_user_info

# 需要导入模块: import httmock [as 别名]
# 或者: from httmock import HTTMock [as 别名]
def test_get_user_info(self):
        with HTTMock(wechat_api_mock):
            self.oauth.fetch_access_token("123456")
            res = self.oauth.get_user_info()
            self.assertEqual("OPENID", res["openid"]) 
开发者ID:wechatpy,项目名称:wechatpy,代码行数:7,代码来源:test_oauth.py

示例6: test_check_access_token

# 需要导入模块: import httmock [as 别名]
# 或者: from httmock import HTTMock [as 别名]
def test_check_access_token(self):
        with HTTMock(wechat_api_mock):
            self.oauth.fetch_access_token("123456")
            res = self.oauth.check_access_token()
            self.assertEqual(True, res) 
开发者ID:wechatpy,项目名称:wechatpy,代码行数:7,代码来源:test_oauth.py

示例7: test_reraise_requests_exception

# 需要导入模块: import httmock [as 别名]
# 或者: from httmock import HTTMock [as 别名]
def test_reraise_requests_exception(self):
        @urlmatch(netloc=r"(.*\.)?api\.weixin\.qq\.com$")
        def _wechat_api_mock(url, request):
            return {"status_code": 404, "content": "404 not found"}

        try:
            with HTTMock(_wechat_api_mock):
                self.oauth.fetch_access_token("123456")
        except WeChatClientException as e:
            self.assertEqual(404, e.response.status_code) 
开发者ID:wechatpy,项目名称:wechatpy,代码行数:12,代码来源:test_oauth.py

示例8: test_get_wechat_ips

# 需要导入模块: import httmock [as 别名]
# 或者: from httmock import HTTMock [as 别名]
def test_get_wechat_ips(self):
        with HTTMock(wechat_api_mock):
            res = self.client.misc.get_wechat_ips()
            self.assertEqual(["127.0.0.1"], res) 
开发者ID:wechatpy,项目名称:wechatpy,代码行数:6,代码来源:test_work_client.py

示例9: test_department_create

# 需要导入模块: import httmock [as 别名]
# 或者: from httmock import HTTMock [as 别名]
def test_department_create(self):
        with HTTMock(wechat_api_mock):
            res = self.client.department.create("Test")
            self.assertEqual(2, res["id"]) 
开发者ID:wechatpy,项目名称:wechatpy,代码行数:6,代码来源:test_work_client.py

示例10: test_department_update

# 需要导入模块: import httmock [as 别名]
# 或者: from httmock import HTTMock [as 别名]
def test_department_update(self):
        with HTTMock(wechat_api_mock):
            res = self.client.department.update(2, "Test 1")
            self.assertEqual(0, res["errcode"]) 
开发者ID:wechatpy,项目名称:wechatpy,代码行数:6,代码来源:test_work_client.py

示例11: test_department_delete

# 需要导入模块: import httmock [as 别名]
# 或者: from httmock import HTTMock [as 别名]
def test_department_delete(self):
        with HTTMock(wechat_api_mock):
            res = self.client.department.delete(2)
            self.assertEqual(0, res["errcode"]) 
开发者ID:wechatpy,项目名称:wechatpy,代码行数:6,代码来源:test_work_client.py

示例12: test_department_get

# 需要导入模块: import httmock [as 别名]
# 或者: from httmock import HTTMock [as 别名]
def test_department_get(self):
        with HTTMock(wechat_api_mock):
            res = self.client.department.get()
            self.assertEqual(2, len(res)) 
开发者ID:wechatpy,项目名称:wechatpy,代码行数:6,代码来源:test_work_client.py

示例13: test_department_get_users_detail

# 需要导入模块: import httmock [as 别名]
# 或者: from httmock import HTTMock [as 别名]
def test_department_get_users_detail(self):
        with HTTMock(wechat_api_mock):
            res = self.client.department.get_users(2, simple=False)
            self.assertEqual(1, len(res)) 
开发者ID:wechatpy,项目名称:wechatpy,代码行数:6,代码来源:test_work_client.py

示例14: test_department_map_users

# 需要导入模块: import httmock [as 别名]
# 或者: from httmock import HTTMock [as 别名]
def test_department_map_users(self):
        with HTTMock(wechat_api_mock):
            users = self.client.department.get_map_users(2, key="email")
            self.assertEqual(users, {"zhangthree@wechat.com": "zhangthree-userid"})

            users = self.client.department.get_map_users(key="mobile")
            self.assertEqual(users, {"15723333333": "zhangthree-userid"}) 
开发者ID:wechatpy,项目名称:wechatpy,代码行数:9,代码来源:test_work_client.py

示例15: test_tag_create

# 需要导入模块: import httmock [as 别名]
# 或者: from httmock import HTTMock [as 别名]
def test_tag_create(self):
        with HTTMock(wechat_api_mock):
            res = self.client.tag.create("test")
            self.assertEqual("1", res["tagid"]) 
开发者ID:wechatpy,项目名称:wechatpy,代码行数:6,代码来源:test_work_client.py


注:本文中的httmock.HTTMock方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。