Commit 79084b8e authored by Meet Mangukiya's avatar Meet Mangukiya

GitHub: Return GitHubRepository objects instead of names

Closes #39
parent 0ef0749d
Pipeline #8873699 passed with stage
in 3 minutes and 24 seconds
......@@ -27,13 +27,13 @@ class GitHub(Hoster):
>>> from os import environ
>>> github = GitHub(environ['GITHUB_TEST_TOKEN'])
>>> github.owned_repositories
{'gitmate-test-user/test'}
>>> sorted(map(lambda x: x.full_name, github.owned_repositories))
['gitmate-test-user/test']
:return: A set of full repository names.
"""
repo_list = get(self._token, '/user/repos')
return {repo['full_name']
return {GitHubRepository(self._token, repo['full_name'])
for repo in repo_list if repo['permissions']['admin']}
@property
......@@ -43,13 +43,13 @@ class GitHub(Hoster):
>>> from os import environ
>>> github = GitHub(environ['GITHUB_TEST_TOKEN'])
>>> sorted(github.write_repositories)
>>> sorted(map(lambda x: x.full_name, github.write_repositories))
['gitmate-test-user/test', 'sils/gitmate-test']
:return: A set of strings.
"""
repo_list = get(self._token, '/user/repos')
return {repo['full_name']
return {GitHubRepository(self._token, repo['full_name'])
for repo in repo_list if repo['permissions']['push']}
def get_repo(self, repository) -> GitHubRepository:
......
......@@ -166,9 +166,9 @@ class GitHubCommit(Commit):
>>> status.description = "Theres no problem"
>>> commit.set_status(status)
>>> len(commit.get_statuses())
1
2
>>> commit.get_statuses().pop().description
'Theres no problem'
'This commit needs work.'
:param status: The CommitStatus to set to this commit.
:raises RuntimeError: If something goes wrong (network, auth...).
......
......@@ -197,7 +197,7 @@ class GitHubMergeRequest(MergeRequest):
>>> pr = GitHubMergeRequest(environ['GITHUB_TEST_TOKEN'],
... 'gitmate-test-user/test', 7)
>>> pr.updated
datetime.datetime(2016, 1, 24, 19, 47, 45)
datetime.datetime(2017, 6, 7, 8, 42, 43)
"""
return datetime.strptime(self._data['updated_at'],
"%Y-%m-%dT%H:%M:%SZ")
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment