|
| 1 | +import github3 |
| 2 | +from mock import patch, Mock |
| 3 | +from tests.utils import (expect, BaseCase, load) |
| 4 | + |
| 5 | +""" |
| 6 | +http://github3py.readthedocs.org/en/0.7.0/github.html#github3.github.GitHub.authorize says scopes are required. |
| 7 | +
|
| 8 | +http://developer.github.com/v3/oauth/#create-a-new-authorization (at time of writing - 2013-09-06) disagrees |
| 9 | +""" |
| 10 | + |
| 11 | + |
| 12 | +class TestOptionalScope(BaseCase): |
| 13 | + def test_authorize_with_scope(self): |
| 14 | + """ Copypasted from TestGitHub """ |
| 15 | + |
| 16 | + self.response('authorization', 201) |
| 17 | + scopes = ['scope1', 'scope2'] |
| 18 | + |
| 19 | + self.g.authorize(None, None, scopes) |
| 20 | + self.not_called() |
| 21 | + |
| 22 | + a = self.g.authorize('user', 'password', scopes) |
| 23 | + expect(a).isinstance(github3.auths.Authorization) |
| 24 | + assert self.request.called is True |
| 25 | + |
| 26 | + self.request.reset_mock() |
| 27 | + |
| 28 | + self.login() |
| 29 | + a = self.g.authorize(None, None, scopes=scopes) |
| 30 | + |
| 31 | + def test_authorize_without_scope(self): |
| 32 | + self.response('authorization', 201) |
| 33 | + |
| 34 | + self.g.authorize(None, None) |
| 35 | + self.not_called() |
| 36 | + |
| 37 | + a = self.g.authorize('user', 'password') |
| 38 | + expect(a).isinstance(github3.auths.Authorization) |
| 39 | + assert self.request.called is True |
| 40 | + |
| 41 | + self.request.reset_mock() |
| 42 | + |
| 43 | + self.login() |
| 44 | + a = self.g.authorize(None, None) |
0 commit comments