Cover all code paths in search_commits (#2087)

The search_commits method was only very lightly tested, meaning over
half of it was not covered. Write another test case, covering all code
paths.
This commit is contained in:
Steve Kowalik
2021-10-22 08:39:31 +11:00
committed by GitHub
parent 93b92cd2fc
commit f1faf941ec
3 changed files with 23 additions and 7 deletions
+3 -7
View File
@@ -598,19 +598,15 @@ class Github:
"""
assert isinstance(query, str), query
url_parameters = dict()
if (
sort is not github.GithubObject.NotSet
): # pragma no branch (Should be covered)
if sort is not github.GithubObject.NotSet:
assert sort in ("author-date", "committer-date"), sort
url_parameters["sort"] = sort
if (
order is not github.GithubObject.NotSet
): # pragma no branch (Should be covered)
if order is not github.GithubObject.NotSet:
assert order in ("asc", "desc"), order
url_parameters["order"] = order
query_chunks = []
if query: # pragma no branch (Should be covered)
if query:
query_chunks.append(query)
for qualifier, value in qualifiers.items():
File diff suppressed because one or more lines are too long
+9
View File
@@ -195,6 +195,15 @@ class Search(Framework.TestCase):
)
self.assertEqual(commits.totalCount, 3)
def testSearchCommits(self):
commits = self.g.search_commits(
query="hash:1265747e992ba7d34a469b6b2f527809f8bf7067",
sort="author-date",
order="asc",
merge="false",
)
self.assertEqual(commits.totalCount, 2)
def testSearchTopics(self):
topics = self.g.search_topics("python", repositories=">950")
self.assertListKeyBegin(