示例#1
0
    def test_getToken_ok(self):
        """
        The GitHub API token is retrieved from the local git repository.
        """
        token_deferred = token.getToken()

        self.assertEqual(
            self.getProcessOutput_calls,
            [('git', ('config', '--get', 'github.token'), os.environ)])

        token_deferred.callback("some token\n")
        self.assertEqual(self.successResultOf(token_deferred), "some token")
示例#2
0
def postGist(reactor, token, files):
    if not token:
        token = yield getToken()

    github = GithubApi(token)

    gistFiles = {}
    if files:
        for name in files:
            with _open(name) as f:
                gistFiles[path.basename(name)] = {"content": f.read()}
    else:
        gistFiles['gistfile1'] = {"content": stdin.read()}

    response = yield github.gists.create(files=gistFiles)
    _print(response['html_url'])