Skip to content

Commit 1971e89

Browse files
committed
🚒 issue shadowed by connect bug
fixing the cassettes, fixing error handling when no gist is present. Signed-off-by: Guyzmo <[email protected]>
1 parent c1b71a6 commit 1971e89

File tree

4 files changed

+76
-46
lines changed

4 files changed

+76
-46
lines changed

git_repo/services/ext/github.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,9 @@ def gist_fetch(self, gist, fname=None):
164164
try:
165165
gist = self.gh.gist(self._format_gist(gist))
166166
except Exception as err:
167-
raise ResourceNotFoundError('Could not find gist') from err
167+
raise ResourceNotFoundError('Error while fetching gist') from err
168+
if not gist:
169+
raise ResourceNotFoundError('Could not find gist')
168170
if gist.files == 1 and not fname:
169171
gist_file = list(gist.iter_files())[0]
170172
else:

tests/integration/cassettes/test_github_test_18_gist_fetch_with_bad_gist.json

Lines changed: 36 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"http_interactions": [
33
{
4-
"recorded_at": "2016-05-12T18:40:11",
4+
"recorded_at": "2016-11-24T21:29:46",
55
"request": {
66
"body": {
77
"encoding": "utf-8",
@@ -22,36 +22,43 @@
2222
"response": {
2323
"body": {
2424
"encoding": "utf-8",
25-
"string": "{\"message\":\"Bad credentials\",\"documentation_url\":\"https://developer.github.com/v3\"}"
25+
"string": "{\"login\":\"<BITBUCKET_NAMESPACE>\",\"id\":254441,\"avatar_url\":\"https://avatars.githubusercontent.com/u/254441?v=3\",\"gravatar_id\":\"\",\"url\":\"https://api.github.com/users/<BITBUCKET_NAMESPACE>\",\"html_url\":\"https://github.com/<BITBUCKET_NAMESPACE>\",\"followers_url\":\"https://api.github.com/users/<BITBUCKET_NAMESPACE>/followers\",\"following_url\":\"https://api.github.com/users/<BITBUCKET_NAMESPACE>/following{/other_user}\",\"gists_url\":\"https://api.github.com/users/<BITBUCKET_NAMESPACE>/gists{/gist_id}\",\"starred_url\":\"https://api.github.com/users/<BITBUCKET_NAMESPACE>/starred{/owner}{/repo}\",\"subscriptions_url\":\"https://api.github.com/users/<BITBUCKET_NAMESPACE>/subscriptions\",\"organizations_url\":\"https://api.github.com/users/<BITBUCKET_NAMESPACE>/orgs\",\"repos_url\":\"https://api.github.com/users/<BITBUCKET_NAMESPACE>/repos\",\"events_url\":\"https://api.github.com/users/<BITBUCKET_NAMESPACE>/events{/privacy}\",\"received_events_url\":\"https://api.github.com/users/<BITBUCKET_NAMESPACE>/received_events\",\"type\":\"User\",\"site_admin\":false,\"name\":\"<BITBUCKET_NAMESPACE>\",\"company\":null,\"blog\":\"http://<BITBUCKET_NAMESPACE>.got.nothing.to/blog/\",\"location\":\"Paris\",\"email\":null,\"hireable\":true,\"bio\":null,\"public_repos\":87,\"public_gists\":17,\"followers\":54,\"following\":15,\"created_at\":\"2010-04-27T14:04:09Z\",\"updated_at\":\"2016-09-03T19:19:47Z\"}"
2626
},
2727
"headers": {
2828
"Access-Control-Allow-Origin": "*",
2929
"Access-Control-Expose-Headers": "ETag, Link, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval",
30-
"Content-Length": "83",
30+
"Cache-Control": "private, max-age=60, s-maxage=60",
31+
"Content-Length": "1118",
3132
"Content-Security-Policy": "default-src 'none'",
3233
"Content-Type": "application/json; charset=utf-8",
33-
"Date": "Thu, 12 May 2016 18:40:20 GMT",
34+
"Date": "Thu, 24 Nov 2016 21:29:45 GMT",
35+
"ETag": "\"552dda7fe01396d75e16d9003f4fd8d7\"",
36+
"Last-Modified": "Sat, 03 Sep 2016 19:19:47 GMT",
3437
"Server": "GitHub.com",
35-
"Status": "401 Unauthorized",
38+
"Status": "200 OK",
3639
"Strict-Transport-Security": "max-age=31536000; includeSubdomains; preload",
40+
"Vary": "Accept, Authorization, Cookie, X-GitHub-OTP",
41+
"X-Accepted-OAuth-Scopes": "",
3742
"X-Content-Type-Options": "nosniff",
3843
"X-Frame-Options": "deny",
3944
"X-GitHub-Media-Type": "github.v3; param=full; format=json",
40-
"X-GitHub-Request-Id": "4EC11365:B215:13F135:5734CE14",
41-
"X-RateLimit-Limit": "60",
42-
"X-RateLimit-Remaining": "59",
43-
"X-RateLimit-Reset": "1463082020",
45+
"X-GitHub-Request-Id": "4EC11365:62A2:12BC52F2:58375BC9",
46+
"X-OAuth-Scopes": "repo, delete_repo, gist",
47+
"X-RateLimit-Limit": "5000",
48+
"X-RateLimit-Remaining": "4955",
49+
"X-RateLimit-Reset": "1480023785",
50+
"X-Served-By": "a7f8a126c9ed3f1c4715a34c0ddc7290",
4451
"X-XSS-Protection": "1; mode=block"
4552
},
4653
"status": {
47-
"code": 401,
48-
"message": "Unauthorized"
54+
"code": 200,
55+
"message": "OK"
4956
},
5057
"url": "https://api.github.com/user"
5158
}
5259
},
5360
{
54-
"recorded_at": "2016-05-12T18:40:11",
61+
"recorded_at": "2016-11-24T21:29:46",
5562
"request": {
5663
"body": {
5764
"encoding": "utf-8",
@@ -72,30 +79,37 @@
7279
"response": {
7380
"body": {
7481
"encoding": "utf-8",
75-
"string": "{\"message\":\"Bad credentials\",\"documentation_url\":\"https://developer.github.com/v3\"}"
82+
"string": "{\"url\":\"https://api.github.com/gists/42\",\"forks_url\":\"https://api.github.com/gists/42/forks\",\"commits_url\":\"https://api.github.com/gists/42/commits\",\"id\":\"42\",\"git_pull_url\":\"https://gist.github.com/42.git\",\"git_push_url\":\"https://gist.github.com/42.git\",\"html_url\":\"https://gist.github.com/42\",\"files\":{\"hint.txt\":{\"filename\":\"hint.txt\",\"type\":\"text/plain\",\"language\":\"Text\",\"raw_url\":\"https://gist.githubusercontent.com/voodootikigod/42/raw/4bca8f9e22a79722555a7d88760751635b0adb1c/hint.txt\",\"size\":26,\"truncated\":false,\"content\":\"The answer to everything.\\n\"}},\"public\":true,\"created_at\":\"2008-07-21T01:45:23Z\",\"updated_at\":\"2015-08-29T13:44:40Z\",\"description\":null,\"comments\":1,\"user\":null,\"comments_url\":\"https://api.github.com/gists/42/comments\",\"owner\":{\"login\":\"voodootikigod\",\"id\":459,\"avatar_url\":\"https://avatars.githubusercontent.com/u/459?v=3\",\"gravatar_id\":\"\",\"url\":\"https://api.github.com/users/voodootikigod\",\"html_url\":\"https://github.com/voodootikigod\",\"followers_url\":\"https://api.github.com/users/voodootikigod/followers\",\"following_url\":\"https://api.github.com/users/voodootikigod/following{/other_user}\",\"gists_url\":\"https://api.github.com/users/voodootikigod/gists{/gist_id}\",\"starred_url\":\"https://api.github.com/users/voodootikigod/starred{/owner}{/repo}\",\"subscriptions_url\":\"https://api.github.com/users/voodootikigod/subscriptions\",\"organizations_url\":\"https://api.github.com/users/voodootikigod/orgs\",\"repos_url\":\"https://api.github.com/users/voodootikigod/repos\",\"events_url\":\"https://api.github.com/users/voodootikigod/events{/privacy}\",\"received_events_url\":\"https://api.github.com/users/voodootikigod/received_events\",\"type\":\"User\",\"site_admin\":false},\"forks\":[],\"history\":[{\"user\":{\"login\":\"defunkt\",\"id\":2,\"avatar_url\":\"https://avatars.githubusercontent.com/u/2?v=3\",\"gravatar_id\":\"\",\"url\":\"https://api.github.com/users/defunkt\",\"html_url\":\"https://github.com/defunkt\",\"followers_url\":\"https://api.github.com/users/defunkt/followers\",\"following_url\":\"https://api.github.com/users/defunkt/following{/other_user}\",\"gists_url\":\"https://api.github.com/users/defunkt/gists{/gist_id}\",\"starred_url\":\"https://api.github.com/users/defunkt/starred{/owner}{/repo}\",\"subscriptions_url\":\"https://api.github.com/users/defunkt/subscriptions\",\"organizations_url\":\"https://api.github.com/users/defunkt/orgs\",\"repos_url\":\"https://api.github.com/users/defunkt/repos\",\"events_url\":\"https://api.github.com/users/defunkt/events{/privacy}\",\"received_events_url\":\"https://api.github.com/users/defunkt/received_events\",\"type\":\"User\",\"site_admin\":true},\"version\":\"3d46fc78188853f358c9e82544173aad560ebd48\",\"committed_at\":\"2011-07-22T17:20:02Z\",\"change_status\":{\"total\":1,\"additions\":1,\"deletions\":0},\"url\":\"https://api.github.com/gists/42/3d46fc78188853f358c9e82544173aad560ebd48\"}],\"truncated\":false}"
7683
},
7784
"headers": {
7885
"Access-Control-Allow-Origin": "*",
7986
"Access-Control-Expose-Headers": "ETag, Link, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval",
80-
"Content-Length": "83",
87+
"Cache-Control": "private, max-age=60, s-maxage=60",
88+
"Content-Length": "2811",
8189
"Content-Security-Policy": "default-src 'none'",
8290
"Content-Type": "application/json; charset=utf-8",
83-
"Date": "Thu, 12 May 2016 18:40:20 GMT",
91+
"Date": "Thu, 24 Nov 2016 21:29:46 GMT",
92+
"ETag": "\"8f1147ffc3085377c5e2810d72e48a59\"",
93+
"Last-Modified": "Mon, 14 Nov 2016 21:21:05 GMT",
8494
"Server": "GitHub.com",
85-
"Status": "401 Unauthorized",
95+
"Status": "200 OK",
8696
"Strict-Transport-Security": "max-age=31536000; includeSubdomains; preload",
97+
"Vary": "Accept, Authorization, Cookie, X-GitHub-OTP",
98+
"X-Accepted-OAuth-Scopes": "",
8799
"X-Content-Type-Options": "nosniff",
88100
"X-Frame-Options": "deny",
89101
"X-GitHub-Media-Type": "github.v3; param=full; format=json",
90-
"X-GitHub-Request-Id": "4EC11365:B215:13F189:5734CE14",
91-
"X-RateLimit-Limit": "60",
92-
"X-RateLimit-Remaining": "58",
93-
"X-RateLimit-Reset": "1463082020",
102+
"X-GitHub-Request-Id": "4EC11365:62A2:12BC530A:58375BC9",
103+
"X-OAuth-Scopes": "repo, delete_repo, gist",
104+
"X-RateLimit-Limit": "5000",
105+
"X-RateLimit-Remaining": "4954",
106+
"X-RateLimit-Reset": "1480023785",
107+
"X-Served-By": "cee4c0729c8e9147e7abcb45b9d69689",
94108
"X-XSS-Protection": "1; mode=block"
95109
},
96110
"status": {
97-
"code": 401,
98-
"message": "Unauthorized"
111+
"code": 200,
112+
"message": "OK"
99113
},
100114
"url": "https://api.github.com/gists/42"
101115
}

0 commit comments

Comments
 (0)