Reproduce issue #134

This commit is contained in:
Vincent Jacques
2013-01-29 19:23:15 +01:00
parent 9db8b896a1
commit 921ba8df1e
4 changed files with 44 additions and 0 deletions
+1
View File
@@ -61,3 +61,4 @@ from Issue54 import *
from Issue80 import *
from Issue87 import *
from Issue133 import *
from Issue134 import *
+33
View File
@@ -0,0 +1,33 @@
# -*- coding: utf-8 -*-
# Copyright 2012 Vincent Jacques
# vincent@vincent-jacques.net
# This file is part of PyGithub. http://vincent-jacques.net/PyGithub
# PyGithub is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License
# as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
# PyGithub is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
# You should have received a copy of the GNU Lesser General Public License along with PyGithub. If not, see <http://www.gnu.org/licenses/>.
import Framework
import github
class Issue134(Framework.BasicTestCase): # https://github.com/jacquev6/PyGithub/pull/134
def testGetAuthorizationsFailsWhenAutenticatedThroughOAuth(self):
g = github.Github(self.oauth_token)
raised = False
try:
list(g.get_user().get_authorizations())
except github.GithubException, exception:
raised = True
self.assertEqual(exception.status, 404)
self.assertTrue(raised)
def testGetAuthorizationsSucceedsWhenAutenticatedThroughLoginPassword(self):
g = github.Github(self.login, self.password)
self.assertListKeyEqual(g.get_user().get_authorizations(), lambda a: a.note, [None, None, 'cligh', None, None, 'GitHub Android App'])
@@ -0,0 +1,5 @@
https GET api.github.com None /authorizations {'Authorization': 'token private_token_removed'} null
404
[('status', '404 Not Found'), ('content-length', '23'), ('x-github-media-type', 'github.beta; format=json'), ('x-content-type-options', 'nosniff'), ('x-ratelimit-remaining', '55'), ('server', 'GitHub.com'), ('connection', 'keep-alive'), ('x-ratelimit-limit', '60'), ('cache-control', ''), ('date', 'Tue, 29 Jan 2013 18:19:32 GMT'), ('content-type', 'application/json; charset=utf-8')]
{"message":"Not Found"}
@@ -0,0 +1,5 @@
https GET api.github.com None /authorizations {'Authorization': 'Basic login_and_password_removed'} null
200
[('status', '200 OK'), ('content-length', '1930'), ('x-github-media-type', 'github.beta; format=json'), ('x-content-type-options', 'nosniff'), ('vary', 'Accept, Authorization, Cookie'), ('x-ratelimit-remaining', '4928'), ('server', 'GitHub.com'), ('last-modified', 'Tue, 29 Jan 2013 17:36:52 GMT'), ('connection', 'keep-alive'), ('x-ratelimit-limit', '5000'), ('etag', '"1ee9c020e28a8e60c0ed7eee863a79fc"'), ('cache-control', 'private, s-maxage=60, max-age=60'), ('date', 'Tue, 29 Jan 2013 18:19:33 GMT'), ('content-type', 'application/json; charset=utf-8')]
[{"token":"private_token_removed","url":"https://api.github.com/authorizations/619306","updated_at":"2012-09-03T08:35:36Z","scopes":[],"created_at":"2012-09-02T15:30:23Z","app":{"url":"http://upverter.com","name":"Upverter"},"note":null,"id":619306,"note_url":null},{"token":"private_token_removed","url":"https://api.github.com/authorizations/648494","updated_at":"2013-01-29T17:36:52Z","scopes":["public_repo","user:email"],"created_at":"2012-09-16T07:13:01Z","app":{"url":"https://travis-ci.org","name":"Travis"},"note":null,"id":648494,"note_url":null},{"token":"private_token_removed","url":"https://api.github.com/authorizations/651653","updated_at":"2012-09-17T21:05:19Z","scopes":["user","repo","gists","delete_repo"],"created_at":"2012-09-17T21:05:19Z","app":{"url":"https://github.com/CMB/cligh","name":"cligh (API)"},"note":"cligh","id":651653,"note_url":"https://github.com/CMB/cligh"},{"token":"private_token_removed","url":"https://api.github.com/authorizations/816763","updated_at":"2012-12-19T09:22:09Z","scopes":[],"created_at":"2012-11-15T17:47:48Z","app":{"url":"https://coderwall.com","name":"coderwall.com"},"note":null,"id":816763,"note_url":null},{"token":"private_token_removed","url":"https://api.github.com/authorizations/974947","updated_at":"2012-12-19T09:17:20Z","scopes":["public_repo"],"created_at":"2012-12-19T09:15:32Z","app":{"url":"http://geekli.st/","name":"Geeklist, Inc."},"note":null,"id":974947,"note_url":null},{"token":"private_token_removed","url":"https://api.github.com/authorizations/1348532","updated_at":"2013-01-27T11:51:21Z","scopes":["repo","user","gist"],"created_at":"2013-01-27T11:51:21Z","app":{"url":"https://github.com/github/android","name":"GitHub Android App (API)"},"note":"GitHub Android App","id":1348532,"note_url":"https://github.com/github/android"}]