Skip to content

Commit

Permalink
Merge pull request #22 from CMUSTRUDEL/dev
Browse files Browse the repository at this point in the history
feat: add support for a single commit details v3 API
  • Loading branch information
user2589 authored Oct 20, 2020
2 parents cb153aa + a44c2cc commit 19a484e
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
6 changes: 6 additions & 0 deletions stscraper/github.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,12 @@ def repo_commits(self, repo_slug):
# https://developer.github.com/v3/repos/commits/#list-commits-on-a-repository
return repo_slug

@api('repos/%s/commits/%s')
def repo_commit(self, repo_slug, commit_hash):
"""Get details for a single commit."""
# https://docs.github.com/en/free-pro-team@latest/rest/reference/repos#get-a-commit
return repo_slug, commit_hash

@api('repos/%s/pulls', paginate=True, state='all')
def repo_pulls(self, repo_slug):
"""Get all repository pull requests.
Expand Down
12 changes: 9 additions & 3 deletions test.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def test_check_print_limits(self):
finally:
sys.stdout = old_stdout

def _test_commits(self, commit):
def _test_commit(self, commit):
self.assertIsInstance(commit, dict)
for prop in ('sha', 'commit', 'author', 'committer', 'parents'):
self.assertIn(prop, commit,
Expand Down Expand Up @@ -156,7 +156,13 @@ def test_repo_commits(self):
commits = self.api.repo_commits(self.repo_address)
self.assertIsInstance(commits, Generator)
commit = next(commits)
self._test_commits(commit)
self._test_commit(commit)

def test_repo_commit(self):
commit = self.api.repo_commit(
'cmustrudel/strudel.scraper', '6adbcd5fbbee057dae4802a2b7099f3f35999e4a')
self.assertIsInstance(commit, dict)
self._test_commit(commit)

def test_repo_pulls(self):
pulls = self.api.repo_pulls(self.repo_address)
Expand All @@ -178,7 +184,7 @@ def test_pull_request_commits(self):
commits = self.api.pull_request_commits(self.repo_address, 22457)
self.assertIsInstance(commits, Generator)
commit = next(commits)
self._test_commits(commit)
self._test_commit(commit)

def test_issue_comments(self):
comments = self.api.issue_comments(self.repo_address, 22473)
Expand Down

0 comments on commit 19a484e

Please sign in to comment.