MCPcopy Create free account
hub / github.com/doraemonext/wechat-python-sdk / api_weixin_mock

Function api_weixin_mock

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

Source from the content-addressed store, hash-verified

13
14@urlmatch(netloc=r'(.*\.)?api\.weixin\.qq\.com$')
15def api_weixin_mock(url, request):
16 path = url.path.replace('/cgi-bin/', '').replace('/', '_')
17 if path.startswith('_'):
18 path = path[1:]
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) as e:
31 print(e)
32 return response(200, content, headers, request=request)

Callers

nothing calls this directly

Calls 1

decodeMethod · 0.45

Tested by

no test coverage detected