8000 test_iter_commits · losingkeys/github3.py@6bc87fb · GitHub
[go: up one dir, main page]

Skip to content

Commit 6bc87fb

Browse files
committed
test_iter_commits
1 parent 8491896 commit 6bc87fb

File tree

2 files changed

+16
-8
lines changed

2 files changed

+16
-8
lines changed

github3/repos.py

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -798,7 +798,7 @@ def iter_comments_on_commit(self, sha, number=1):
798798
url = self._build_url('commits', sha, 'comments', base_url=self._api)
799799
return self._iter(int(number), url, RepoComment)
800800

801-
def iter_commits(self, sha='', path='', author='', number=-1):
801+
def iter_commits(self, sha=None, path=None, author=None, number=-1):
802802
"""Iterate over commits in this repository.
803803
804804
:param str sha: (optional), sha or branch to start listing commits
@@ -812,13 +812,8 @@ def iter_commits(self, sha='', path='', author='', number=-1):
812812
813813
:returns: list of :class:`RepoCommit <RepoCommit>`\ s
814814
"""
815-
params = {}
816-
if sha:
817-
params['sha'] = sha
818-
if path:
819-
params['path'] = path
820-
if author:
821-
params['author'] = author
815+
params = {'sha': sha, 'path': path, 'author': author}
816+
self._remove_none(params)
822817
url = self._build_url('commits', base_url=self._api)
823818
return self._iter(int(number), url, RepoCommit, params=params)
824819

tests/test_repos.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -531,3 +531,16 @@ def test_iter_comments_on_commit(self):
531531
c = next(self.repo.iter_comments_on_commit('fakesha'))
532532
expect(c).isinstance(github3.repos.RepoComment)
533533
self.mock_assertions()
534+
535+
def test_iter_commits(self):
536+
self.response('commit', _iter=True)
537+
self.get(self.api + 'commits')
538+
self.conf = {'params': {}}
539+
540+
c = next(self.repo.iter_commits())
541+
expect(c).isinstance(github3.repos.RepoCommit)
542+
self.mock_assertions()
543+
544+
self.conf = {'params': {'sha': 'fakesha', 'path': '/'}}
545+
c = next(self.repo.iter_commits('fakesha', '/'))
546+
self.mock_assertions()

0 commit comments

Comments
 (0)
0