Skip to content

Commit

Permalink
Merge pull request #162 from github/auth-test-coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
jmeridth authored Nov 5, 2024
2 parents bfb9ffa + b099bdc commit 9fc2ce6
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions test_auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,22 @@ def test_auth_to_github_with_app(self, mock_gh):
mock.login_as_app_installation.assert_called_once()
self.assertEqual(result, mock)

@patch("github3.login")
def test_auth_to_github_invalid_credentials(self, mock_login):
"""
Test the auth_to_github function raises correct ValueError
when credentials are present but incorrect.
"""
mock_login.return_value = None
with self.assertRaises(ValueError) as context_manager:
auth.auth_to_github("not_a_valid_token", "", "", b"", "", False)

the_exception = context_manager.exception
self.assertEqual(
str(the_exception),
"Unable to authenticate to GitHub",
)


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

0 comments on commit 9fc2ce6

Please sign in to comment.