MCPcopy
hub / github.com/wechatpy/wechatpy / wechat_api_mock

Function wechat_api_mock

tests/test_component_api.py:17–32  ·  view source on GitHub ↗
(url, request)

Source from the content-addressed store, hash-verified

15
16@urlmatch(netloc=r'(.*\.)?api\.weixin\.qq\.com$')
17def wechat_api_mock(url, request):
18 path = url.path.replace('/cgi-bin/component/', '').replace('/', '_')
19 res_file = os.path.join(_FIXTURE_PATH, '%s.json' % path)
20 content = {
21 'errcode': 99999,
22 'errmsg': 'can not find fixture %s' % res_file,
23 }
24 headers = {
25 'Content-Type': 'application/json'
26 }
27 try:
28 with open(res_file, 'rb') as f:
29 content = json.loads(f.read().decode('utf-8'))
30 except (IOError, ValueError):
31 pass
32 return response(200, content, headers, request=request)
33
34
35class WeChatComponentTestCase(unittest.TestCase):

Callers

nothing calls this directly

Calls 1

decodeMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…