Skip to content

Commit

Permalink
Fixes #6
Browse files Browse the repository at this point in the history
Bad copypasta on some argument parsing logic
  • Loading branch information
mschwager committed Feb 7, 2018
1 parent f07d4db commit 87954d6
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/gitem/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ def get_repository_contributors(self, owner, repository, anon=None):
https://developer.github.com/v3/repos/#list-contributors
"""
anon_values = [1, "true"]
if anon not in anon_values and type is not None:
if anon not in anon_values and anon is not None:
raise ValueError("anon must be one of {}".format(anon_values))

method = "GET"
Expand Down
21 changes: 21 additions & 0 deletions tests/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,27 @@ def test_get_repository_contributors_bad_anon(self):
with self.assertRaises(ValueError):
ghapi.get_repository_contributors("UNUSED", "UNUSED", anon=anon)

def test_get_repository_contributors_ok(self):
mocked_json_values = [
mocked_api_results.get_result_value(result)
for result in mocked_api_results.PAGED_API_RESULT
]

mocked_status_codes = [
mocked_api_results.get_result_status_code(result)
for result in mocked_api_results.PAGED_API_RESULT
]

mocked_api = self.paged_api_will_return(mocked_json_values, mocked_status_codes)

for result, status_code in mocked_api.get_repository_contributors("unused", "unused"):
expected = mocked_api_results.get_result_value(
mocked_api_results.STANDARD_API_RESULT
)

self.assertOk(status_code)
self.assertEqual(result, expected)


if __name__ == "__main__":
unittest.main()

0 comments on commit 87954d6

Please sign in to comment.