def browse(args): """ Print the GitHub API response at the given URL """ with cli.catch_api_errors(): client = GithubAPIClient(nickname=args.github) res = client.request(args.method, args.url, _raise=False) print('HTTP/1.1 {0} {1}'.format(res.status_code, res.reason)) for k, v in res.headers.items(): print("{0}: {1}".format(k, v)) print() if res.json() is not None: print(json.dumps(res.json(), indent=2)) else: print(res.content)
def browse(args): """ Print the GitHub API response at the given URL """ with cli.catch_api_errors(): client = GithubAPIClient(nickname=args.github) res = client.request(args.method, args.url, _raise=False) print('HTTP/1.1 {0} {1}'.format(res.status_code, res.reason)) for k, v in res.headers.items(): print("{0}: {1}".format(k, v)) print() if res.json() is not None: print(json.dumps(res.json(), indent=2)) else: print(res.content)
def test_request(self): self.register_response('options', API_ROOT + '/foo', 200, {}, 'foo') c = GithubAPIClient(nickname='test') assert_equal(c.request('options', '/foo').content, 'foo')