@@ -25,33 +25,49 @@ def test_auth_to_github_with_github_app(self, mock_login):
2525 parameters provided.
2626 """
2727 mock_login .return_value = MagicMock ()
28- result = auth_to_github (12345 , 678910 , b"hello" , "" , "" )
28+ result = auth_to_github ("" , 12345 , 678910 , b"hello" , "" , False )
2929
30- self .assertIsInstance (result , github3 .github .GitHub )
30+ self .assertIsInstance (result , github3 .github .GitHub , False )
3131
3232 def test_auth_to_github_with_token (self ):
3333 """
3434 Test the auth_to_github function when the token is provided.
3535 """
36- result = auth_to_github (None , None , b"" , "token " , "" )
36+ result = auth_to_github ("token" , None , None , b"" , "" , False )
3737
38- self .assertIsInstance (result , github3 .github .GitHub )
38+ self .assertIsInstance (result , github3 .github .GitHub , False )
3939
4040 def test_auth_to_github_without_authentication_information (self ):
4141 """
4242 Test the auth_to_github function when authentication information is not provided.
4343 Expect a ValueError to be raised.
4444 """
4545 with self .assertRaises (ValueError ):
46- auth_to_github (None , None , b"" , "" , "" )
46+ auth_to_github ("" , None , None , b"" , "" , False )
4747
4848 def test_auth_to_github_with_ghe (self ):
4949 """
5050 Test the auth_to_github function when the GitHub Enterprise URL is provided.
5151 """
52- result = auth_to_github (None , None , b"" , "token" , "https://github.example.com" )
52+ result = auth_to_github (
53+ "token" , None , None , b"" , "https://github.example.com" , False
54+ )
55+
56+ self .assertIsInstance (result , github3 .github .GitHubEnterprise , False )
5357
54- self .assertIsInstance (result , github3 .github .GitHubEnterprise )
58+ @patch ("github3.github.GitHubEnterprise" )
59+ def test_auth_to_github_with_ghe_and_ghe_app (self , mock_ghe ):
60+ """
61+ Test the auth_to_github function when the GitHub Enterprise URL \
62+ is provided and the app was created in GitHub Enterprise URL.
63+ """
64+ mock = mock_ghe .return_value
65+ mock .login_as_app_installation = MagicMock (return_value = True )
66+ result = auth_to_github (
67+ "" , "123" , "123" , b"123" , "https://github.example.com" , True
68+ )
69+ mock .login_as_app_installation .assert_called_once ()
70+ self .assertEqual (result , mock )
5571
5672 @patch ("github3.apps.create_jwt_headers" , MagicMock (return_value = "gh_token" ))
5773 @patch ("requests.post" )
@@ -64,9 +80,10 @@ def test_get_github_app_installation_token(self, mock_post):
6480 mock_response .raise_for_status .return_value = None
6581 mock_response .json .return_value = {"token" : dummy_token }
6682 mock_post .return_value = mock_response
83+ mock_ghe = ""
6784
6885 result = get_github_app_installation_token (
69- b"gh_private_token" , "gh_app_id" , "gh_installation_id"
86+ mock_ghe , b"gh_private_token" , "gh_app_id" , "gh_installation_id"
7087 )
7188
7289 self .assertEqual (result , dummy_token )
0 commit comments