44from oauthlib .oauth2 .rfc6749 .errors import MismatchingStateError , InvalidGrantError
55from django .test .client import RequestFactory
66from django .core .urlresolvers import reverse
7+ import oauthadmin .views
78
89
910SESSION_VARIABLES = ['oauth_state' , 'oauth_token' , 'uid' , 'user' ]
@@ -41,7 +42,7 @@ def test_login(app_setting, OAuth2Session, request_factory):
4142 OAuth2Session .return_value = mock .Mock (
4243 authorization_url = mock .Mock (return_value = ('https://foo' , 'state-variable' ))
4344 )
44- request = request_factory .get (reverse (' oauthadmin.views.login' ))
45+ request = request_factory .get (reverse (oauthadmin .views .login ))
4546 request .session = {}
4647 request .build_absolute_uri = mock .Mock (return_value = 'https://test.com/construct-redirect' )
4748
@@ -57,7 +58,7 @@ def test_login_redirect_uri(OAuth2Session, request_factory):
5758 OAuth2Session .return_value = mock .Mock (
5859 authorization_url = mock .Mock (return_value = ('https://foo' , 'state-variable' ))
5960 )
60- request = request_factory .get (reverse (' oauthadmin.views.login' ))
61+ request = request_factory .get (reverse (oauthadmin .views .login ))
6162 request .session = {}
6263 request .build_absolute_uri = mock .Mock (return_value = 'https://test.com/construct-redirect' )
6364
@@ -74,7 +75,7 @@ def test_login_redirect_uri_with_next_from_url(OAuth2Session, request_factory):
7475 OAuth2Session .return_value = mock .Mock (
7576 authorization_url = mock .Mock (return_value = ('https://foo' , 'state-variable' ))
7677 )
77- request = request_factory .get (reverse (' oauthadmin.views.login' ) + '?next=/admin/content/' )
78+ request = request_factory .get (reverse (oauthadmin .views .login ) + '?next=/admin/content/' )
7879 request .session = {}
7980 request .build_absolute_uri = mock .Mock (return_value = 'https://test.com/construct-redirect' )
8081
@@ -143,7 +144,7 @@ def test_callback_with_invalid_grant(import_by_path, app_setting, OAuth2Session,
143144@mock .patch ('oauthadmin.views.app_setting' )
144145@mock .patch ('oauthadmin.views.import_by_path' )
145146def test_callback (import_by_path , app_setting , OAuth2Session , request_factory ):
146- request = request_factory .get (reverse (' oauthadmin.views.callback' ))
147+ request = request_factory .get (reverse (oauthadmin .views .callback ))
147148 request .session = {'oauth_state' : 'state-variable' }
148149 OAuth2Session .return_value = mock .Mock (
149150 fetch_token = mock .Mock (return_value = 'token' )
@@ -163,7 +164,7 @@ def test_callback(import_by_path, app_setting, OAuth2Session, request_factory):
163164@mock .patch ('oauthadmin.views.app_setting' )
164165@mock .patch ('oauthadmin.views.import_by_path' )
165166def test_callback_redirect_to_next (import_by_path , app_setting , OAuth2Session , request_factory ):
166- request = request_factory .get (reverse (' oauthadmin.views.callback' ) + '?next=/admin/content/' )
167+ request = request_factory .get (reverse (oauthadmin .views .callback ) + '?next=/admin/content/' )
167168 request .session = {'oauth_state' : 'state-variable' }
168169 OAuth2Session .return_value = mock .Mock (
169170 fetch_token = mock .Mock (return_value = 'token' )
0 commit comments