@@ -9,6 +9,7 @@ def __init__(self, status_code, json, raise_error, headers={'X-RateLimit-Remaini
99 self .raise_error = raise_error
1010 self .text = json
1111 self .headers = headers
12+ self .content = "github"
1213
1314 def raise_for_status (self ):
1415 if not self .raise_error :
@@ -26,7 +27,7 @@ def get_response(status_code, json={}, raise_error=False):
2627class TestCredentials (unittest .TestCase ):
2728
2829 def test_repo_not_found (self , mocked_request ):
29- json = {"message" : "Not Found" , "documentation_url" : "https:/" }
30+ json = {"message" : "Not Found" , "documentation_url" : "https:/docs.github.com/ " }
3031 mocked_request .return_value = get_response (404 , json , True )
3132
3233 try :
@@ -43,49 +44,14 @@ def test_repo_bad_request(self, mocked_request):
4344 self .assertEquals (str (e ), "HTTP-error-code: 400, Error: The request is missing or has a bad parameter." )
4445
4546 def test_repo_bad_creds (self , mocked_request ):
46- json = {"message" : "Bad credentials" , "documentation_url" : "https://docs.github.com/rest " }
47+ json = {"message" : "Bad credentials" , "documentation_url" : "https://docs.github.com/" }
4748 mocked_request .return_value = get_response (401 , json , True )
4849
4950 try :
5051 tap_github .verify_repo_access ("" , "repo" )
5152 except tap_github .BadCredentialsException as e :
5253 self .assertEquals (str (e ), "HTTP-error-code: 401, Error: {}" .format (json ))
5354
54- def test_org_not_found (self , mocked_request ):
55- json = {"message" : "Not Found" , "documentation_url" : "https:/" }
56- mocked_request .return_value = get_response (404 , json , True )
57-
58- try :
59- tap_github .verify_org_access ("" , "personal-repo" )
60- except tap_github .NotFoundException as e :
61- self .assertEquals (str (e ), "HTTP-error-code: 404, Error: 'personal-repo' is not an organization." )
62-
63- def test_org_bad_request (self , mocked_request ):
64- mocked_request .return_value = get_response (400 , raise_error = True )
65-
66- try :
67- tap_github .verify_org_access ("" , "personal-repo" )
68- except tap_github .BadRequestException as e :
69- self .assertEquals (str (e ), "HTTP-error-code: 400, Error: The request is missing or has a bad parameter." )
70-
71- def test_org_forbidden (self , mocked_request ):
72- json = {'message' : 'Must have admin rights to Repository.' , 'documentation_url' : 'https://docs.github.com/rest/reference/' }
73- mocked_request .return_value = get_response (403 , json , True )
74-
75- try :
76- tap_github .verify_org_access ("" , "personal-repo" )
77- except tap_github .AuthException as e :
78- self .assertEquals (str (e ), "HTTP-error-code: 403, Error: {}" .format (json ))
79-
80- def test_org_bad_creds (self , mocked_request ):
81- json = {"message" : "Bad credentials" , "documentation_url" : "https://docs.github.com/rest" }
82- mocked_request .return_value = get_response (401 , json , True )
83-
84- try :
85- tap_github .verify_org_access ("" , "personal-repo" )
86- except tap_github .BadCredentialsException as e :
87- self .assertEquals (str (e ), "HTTP-error-code: 401, Error: {}" .format (json ))
88-
8955 @mock .patch ("tap_github.get_catalog" )
9056 def test_discover_valid_creds (self , mocked_get_catalog , mocked_request ):
9157 mocked_request .return_value = get_response (200 )
@@ -97,7 +63,7 @@ def test_discover_valid_creds(self, mocked_get_catalog, mocked_request):
9763
9864 @mock .patch ("tap_github.get_catalog" )
9965 def test_discover_not_found (self , mocked_get_catalog , mocked_request ):
100- json = {"message" : "Not Found" , "documentation_url" : "https:/" }
66+ json = {"message" : "Not Found" , "documentation_url" : "https:/docs.github.com/ " }
10167 mocked_request .return_value = get_response (404 , json , True )
10268 mocked_get_catalog .return_value = {}
10369
@@ -120,7 +86,7 @@ def test_discover_bad_request(self, mocked_get_catalog, mocked_request):
12086
12187 @mock .patch ("tap_github.get_catalog" )
12288 def test_discover_bad_creds (self , mocked_get_catalog , mocked_request ):
123- json = {"message" :"Bad credentials" ,"documentation_url" :"https://docs.github.com/rest " }
89+ json = {"message" :"Bad credentials" ,"documentation_url" :"https://docs.github.com/" }
12490 mocked_request .return_value = get_response (401 , json , True )
12591 mocked_get_catalog .return_value = {}
12692
@@ -132,7 +98,7 @@ def test_discover_bad_creds(self, mocked_get_catalog, mocked_request):
13298
13399 @mock .patch ("tap_github.get_catalog" )
134100 def test_discover_forbidden (self , mocked_get_catalog , mocked_request ):
135- json = {'message' : 'Must have admin rights to Repository.' , 'documentation_url' : 'https://docs.github.com/rest/reference/ ' }
101+ json = {'message' : 'Must have admin rights to Repository.' , 'documentation_url' : 'https://docs.github.com/' }
136102 mocked_request .return_value = get_response (403 , json , True )
137103 mocked_get_catalog .return_value = {}
138104
@@ -145,19 +111,16 @@ def test_discover_forbidden(self, mocked_get_catalog, mocked_request):
145111
146112@mock .patch ("tap_github.logger.info" )
147113@mock .patch ("tap_github.verify_repo_access" )
148- @mock .patch ("tap_github.verify_org_access" )
149114class TestRepoCallCount (unittest .TestCase ):
150- def test_repo_call_count (self , mocked_org , mocked_repo , mocked_logger_info ):
115+ def test_repo_call_count (self , mocked_repo , mocked_logger_info ):
151116 """
152117 Here 3 repos are given,
153118 so tap will check creds for all 3 repos
154119 """
155- mocked_org .return_value = None
156120 mocked_repo .return_value = None
157121
158122 config = {"access_token" : "access_token" , "repository" : "org1/repo1 org1/repo2 org2/repo1" }
159- tap_github .verify_access_for_repo_org (config )
123+ tap_github .verify_access_for_repo (config )
160124
161125 self .assertEquals (mocked_logger_info .call_count , 3 )
162- self .assertEquals (mocked_org .call_count , 3 )
163126 self .assertEquals (mocked_repo .call_count , 3 )
0 commit comments