(url, request)
| 18 | |
| 19 | @urlmatch(netloc=r'(.*\.)?api\.weixin\.qq\.com$') |
| 20 | def 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 | |
| 43 | class WeChatClientTestCase(unittest.TestCase): |
no test coverage detected
searching dependent graphs…