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

Function wechat_api_mock

tests/test_basic.py:25–42  ·  view source on GitHub ↗
(url, request)

Source from the content-addressed store, hash-verified

23
24@urlmatch(netloc=r'(.*\.)?api\.weixin\.qq\.com$')
25def wechat_api_mock(url, request):
26 path = url.path.replace('/cgi-bin/', '').replace('/', '_')
27 if path.startswith('_'):
28 path = path[1:]
29 res_file = os.path.join(FIXTURE_PATH, '%s.json' % path)
30 content = {
31 'errcode': 99999,
32 'errmsg': 'can not find fixture %s' % res_file,
33 }
34 headers = {
35 'Content-Type': 'application/json'
36 }
37 try:
38 with open(res_file, 'rb') as f:
39 content = json.loads(f.read().decode('utf-8'))
40 except (IOError, ValueError) as e:
41 print(e)
42 return response(200, content, headers, request=request)
43
44
45class WechatBasicTestCase(unittest.TestCase):

Callers

nothing calls this directly

Calls 1

decodeMethod · 0.45

Tested by

no test coverage detected