當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。