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

Function wechat_api_mock

tests/test_client.py:20–40  ·  view source on GitHub ↗
(url, request)

Source from the content-addressed store, hash-verified

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

Callers 1

next_openid_mockMethod · 0.70

Calls 1

decodeMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…