Skip to content

Commit

Permalink
Make session work with DeviceIDAuthorizer and ImplicitAuthorizer.
Browse files Browse the repository at this point in the history
  • Loading branch information
bboe committed Aug 8, 2016
1 parent f1f6214 commit 8e437c4
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 2 deletions.
8 changes: 8 additions & 0 deletions CHANGES.rst
Expand Up @@ -4,6 +4,14 @@ Change Log
prawcore follows `semantic versioning <http://semver.org/>`_ with the exception
that deprecations will not be announced by a minor release.

Unreleased
----------

**Fixed**

* ``session`` works with ``DeviceIDAuthorizer`` and ``ImplicitAuthorizer``.


0.2.0 (2016-08-07)
------------------

Expand Down
4 changes: 2 additions & 2 deletions prawcore/sessions.py
Expand Up @@ -4,7 +4,7 @@
from requests.compat import urljoin
from requests.status_codes import codes

from .auth import Authorizer
from .auth import BaseAuthorizer
from .rate_limit import RateLimiter
from .exceptions import (BadRequest, InvalidInvocation, NotFound, Redirect,
ServerError)
Expand Down Expand Up @@ -36,7 +36,7 @@ def __init__(self, authorizer):
:param authorizer: An instance of :class:`Authorizer`.
"""
if not isinstance(authorizer, Authorizer):
if not isinstance(authorizer, BaseAuthorizer):
raise InvalidInvocation('invalid Authorizer: {}'
.format(authorizer))
self._authorizer = authorizer
Expand Down
10 changes: 10 additions & 0 deletions tests/test_sessions.py
Expand Up @@ -53,6 +53,16 @@ def test_context_manager(self):
def test_init__without_authenticator(self):
self.assertRaises(prawcore.InvalidInvocation, prawcore.Session, None)

def test_init__with_device_id_authorizer(self):
authenticator = prawcore.UntrustedAuthenticator(REQUESTOR, CLIENT_ID)
authorizer = prawcore.DeviceIDAuthorizer(authenticator)
prawcore.Session(authorizer)

def test_init__with_implicit_authorizer(self):
authenticator = prawcore.UntrustedAuthenticator(REQUESTOR, CLIENT_ID)
authorizer = prawcore.ImplicitAuthorizer(authenticator, None, 0, '')
prawcore.Session(authorizer)

def test_request__get(self):
with Betamax(REQUESTOR).use_cassette('Session_request__get'):
session = prawcore.Session(readonly_authorizer())
Expand Down

0 comments on commit 8e437c4

Please sign in to comment.