Python httmock.HTTMock() Examples
The following are 30
code examples of httmock.HTTMock().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
httmock
, or try the search function
.
Example #1
Source File: test_work_client.py From wechatpy with MIT License | 6 votes |
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"])
Example #2
Source File: test_session.py From wechatpy with MIT License | 6 votes |
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)
Example #3
Source File: test_work_client.py From wechatpy with MIT License | 5 votes |
def test_invoice_update_status_with_empty_status(self): with HTTMock(wechat_api_mock): self.assertRaises( ValueError, self.client.invoice.update_status, card_id="CARDID", encrypt_code="ENCRYPTCODE", reimburse_status="", )
Example #4
Source File: test_external_contact.py From wechatpy with MIT License | 5 votes |
def test_ec_del_corp_tag(self): with HTTMock(wechat_api_mock): res = self.client.external_contact.del_corp_tag(tag_id=["etm7wjCgAAADvErs_p_VhdNdN6-i2zAg"]) self.assertEqual(0, res["errcode"])
Example #5
Source File: test_client.py From wechatpy with MIT License | 5 votes |
def test_upload_media(self): media_file = io.StringIO("nothing") with HTTMock(wechat_api_mock): media = self.client.media.upload("image", media_file) self.assertEqual("image", media["type"]) self.assertEqual("12345678", media["media_id"])
Example #6
Source File: test_client.py From wechatpy with MIT License | 5 votes |
def test_user_get_group_id(self): with HTTMock(wechat_api_mock): group_id = self.client.user.get_group_id("123456") self.assertEqual(102, group_id)
Example #7
Source File: test_client.py From wechatpy with MIT License | 5 votes |
def test_fetch_access_token(self): with HTTMock(wechat_api_mock): token = self.client.fetch_access_token() self.assertEqual("1234567890", token["access_token"]) self.assertEqual(7200, token["expires_in"]) self.assertEqual("1234567890", self.client.access_token)
Example #8
Source File: test_payment.py From wechatpy with MIT License | 5 votes |
def test_apply_deduct(self): with HTTMock(wechat_api_mock): response = self.client.withhold.apply_deduct(body="测试商品", total_fee=999, contract_id="203", notify_url="") self.assertEqual(response["result_code"], "SUCCESS")
Example #9
Source File: test_payment.py From wechatpy with MIT License | 5 votes |
def test_query_signing(self): with HTTMock(wechat_api_mock): response = self.client.withhold.query_signing(contract_id="test1234") self.assertEqual(response["result_code"], "SUCCESS")
Example #10
Source File: test_session.py From wechatpy with MIT License | 5 votes |
def test_redis_session_storage_access_token(self): from redis import Redis from wechatpy.session.redisstorage import RedisStorage redis = Redis() session = RedisStorage(redis) 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)
Example #11
Source File: test_session.py From wechatpy with MIT License | 5 votes |
def test_memory_session_storage_access_token(self): client = WeChatClient(self.app_id, self.secret) 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)
Example #12
Source File: test_payment.py From wechatpy with MIT License | 5 votes |
def test_apply_cancel_signing(self): with HTTMock(wechat_api_mock): response = self.client.withhold.apply_cancel_signing(plan_id="t1234", contract_code="w1111",) self.assertEqual(response["result_code"], "SUCCESS")
Example #13
Source File: test_component_api.py From wechatpy with MIT License | 5 votes |
def test_create_preauthcode(self): with HTTMock(wechat_api_mock): result = self.client.create_preauthcode() self.assertEqual("1234567890", result["pre_auth_code"]) self.assertEqual(600, result["expires_in"])
Example #14
Source File: test_component_api.py From wechatpy with MIT License | 5 votes |
def test_fetch_access_token(self): with HTTMock(wechat_api_mock): token = self.client.fetch_access_token() self.assertEqual("1234567890", token["component_access_token"]) self.assertEqual(7200, token["expires_in"]) self.assertEqual("1234567890", self.client.access_token)
Example #15
Source File: test_work_client.py From wechatpy with MIT License | 5 votes |
def test_invoice_update_status_batch_with_empty_invoice_list(self): with HTTMock(wechat_api_mock): openid = "OPENID" reimburse_status = "INVOICE_REIMBURSE_INIT" invoice_list = [] self.assertRaises( ValueError, self.client.invoice.update_status_batch, openid=openid, reimburse_status=reimburse_status, invoice_list=invoice_list, )
Example #16
Source File: test_work_client.py From wechatpy with MIT License | 5 votes |
def test_invoice_update_status_batch_with_invalid_status(self): with HTTMock(wechat_api_mock): openid = "OPENID" reimburse_status = "" invoice_list = [ {"card_id": "cardid_1", "encrypt_code": "encrypt_code_1"}, {"card_id": "cardid_2", "encrypt_code": "encrypt_code_2"}, ] self.assertRaises( ValueError, self.client.invoice.update_status_batch, openid=openid, reimburse_status=reimburse_status, invoice_list=invoice_list, )
Example #17
Source File: test_work_client.py From wechatpy with MIT License | 5 votes |
def test_invoice_update_status_batch(self): with HTTMock(wechat_api_mock): openid = "OPENID" reimburse_status = "INVOICE_REIMBURSE_INIT" invoice_list = [ {"card_id": "cardid_1", "encrypt_code": "encrypt_code_1"}, {"card_id": "cardid_2", "encrypt_code": "encrypt_code_2"}, ] res = self.client.invoice.update_status_batch(openid, reimburse_status, invoice_list) self.assertEqual(0, res["errcode"])
Example #18
Source File: test_component_api.py From wechatpy with MIT License | 5 votes |
def test_refresh_authorizer_token(self): appid = "appid" refresh_token = "refresh_token" with HTTMock(wechat_api_mock): result = self.client.refresh_authorizer_token(appid, refresh_token) self.assertEqual("1234567890", result["authorizer_access_token"]) self.assertEqual("123456789", result["authorizer_refresh_token"]) self.assertEqual(7200, result["expires_in"])
Example #19
Source File: test_work_client.py From wechatpy with MIT License | 5 votes |
def test_invoice_update_status(self): with HTTMock(wechat_api_mock): card_id = "CARDID" encrypt_code = "ENCRYPTCODE" reimburse_status = "INVOICE_REIMBURSE_INIT" res = self.client.invoice.update_status(card_id, encrypt_code, reimburse_status) self.assertEqual(0, res["errcode"])
Example #20
Source File: test_work_client.py From wechatpy with MIT License | 5 votes |
def test_invoice_get_info_batch_with_empty_item_list(self): with HTTMock(wechat_api_mock): self.assertRaises(ValueError, self.client.invoice.get_info_batch, item_list=[])
Example #21
Source File: test_work_client.py From wechatpy with MIT License | 5 votes |
def test_invoice_get_info_batch(self): with HTTMock(wechat_api_mock): item_list = [ {"card_id": "CARDID1", "encrypt_code": "ENCRYPTCODE1"}, {"card_id": "CARDID2", "encrypt_code": "ENCRYPTCODE2"}, ] res = self.client.invoice.get_info_batch(item_list) self.assertEqual(0, res["errcode"])
Example #22
Source File: test_work_client.py From wechatpy with MIT License | 5 votes |
def test_invoice_get_info(self): with HTTMock(wechat_api_mock): res = self.client.invoice.get_info(card_id="CARDID", encrypt_code="ENCRYPTCODE") self.assertEqual(0, res["errcode"])
Example #23
Source File: test_work_client.py From wechatpy with MIT License | 5 votes |
def test_oa_get_checkin_option(self): with HTTMock(wechat_api_mock): res = self.client.oa.get_checkin_option(datetime=1511971200, userid_list=["james", "paul"]) self.assertIsInstance(res, dict, msg="the returned result should be dict type") self.assertEqual(0, res["errcode"])
Example #24
Source File: test_work_client.py From wechatpy with MIT License | 5 votes |
def test_oa_get_checkin_data_with_invalid_timestamp(self): with HTTMock(wechat_api_mock): self.assertRaises( ValueError, self.client.oa.get_checkin_data, data_type=5, start_time=1492790400, end_time=1492617600, userid_list=["james", "paul"], )
Example #25
Source File: test_work_client.py From wechatpy with MIT License | 5 votes |
def test_oa_get_checkin_data_with_invalid_datatype(self): with HTTMock(wechat_api_mock): self.assertRaises( ValueError, self.client.oa.get_checkin_data, data_type=5, start_time=1492617600, end_time=1492790400, userid_list=["james", "paul"], )
Example #26
Source File: test_work_client.py From wechatpy with MIT License | 5 votes |
def test_oa_get_checkin_data(self): with HTTMock(wechat_api_mock): res = self.client.oa.get_checkin_data( data_type=3, start_time=1492617600, end_time=1492790400, userid_list=["james", "paul"] ) self.assertIsInstance(res, dict, msg="the returned result should be dict type") self.assertEqual(0, res["errcode"])
Example #27
Source File: test_work_client.py From wechatpy with MIT License | 5 votes |
def test_os_get_dial_record_with_invalid_timestamp(self): with HTTMock(wechat_api_mock): self.assertRaises( ValueError, self.client.oa.get_dial_record, start_time=1536940800, end_time=1536508800, offset=0, limit=100, )
Example #28
Source File: test_work_client.py From wechatpy with MIT License | 5 votes |
def test_external_contact_transfer(self): with HTTMock(wechat_api_mock): res = self.client.external_contact.transfer("woAJ2GCAAAXtWyujaWJHDDGi0mACH71w", "zhangsan", "lisi") self.assertEqual(0, res["errcode"])
Example #29
Source File: test_work_client.py From wechatpy with MIT License | 5 votes |
def test_external_contact_get_unassigned_list(self): with HTTMock(wechat_api_mock): res = self.client.external_contact.get_unassigned_list(0, 100) self.assertEqual(0, res["errcode"])
Example #30
Source File: test_work_client.py From wechatpy with MIT License | 5 votes |
def test_external_contact_get_user_behavior_data(self): with HTTMock(wechat_api_mock): res = self.client.external_contact.get_user_behavior_data(["zhangsan", "lisi"], 1536508800, 1536940800) self.assertEqual(0, res["errcode"])