Skip to content

Commit fec119f

Browse files
committed
more on code with flake8
1 parent 576f34d commit fec119f

13 files changed

+30
-30
lines changed

oauth2_provider/admin.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
from .models import Grant, AccessToken, RefreshToken, get_application_model
44

5+
56
class RawIDAdmin(admin.ModelAdmin):
67
raw_id_fields = ('user',)
78

oauth2_provider/compat.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,4 +36,4 @@
3636
from django.apps import apps
3737
get_model = apps.get_model
3838
except ImportError:
39-
from django.db.models import get_model
39+
from django.db.models import get_model

oauth2_provider/decorators.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ def my_view(request):
1919
# An access token is required to get here...
2020
# ...
2121
pass
22-
2322
"""
2423
_scopes = scopes or []
2524

oauth2_provider/ext/rest_framework/permissions.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,4 +59,3 @@ def get_scopes(self, request, view):
5959
read_write_scope = oauth2_settings.WRITE_SCOPE
6060

6161
return required_scopes + [read_write_scope]
62-

oauth2_provider/models.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,8 @@ def redirect_uri_allowed(self, uri):
9494
parsed_uri = urlparse(uri)
9595

9696
if (parsed_allowed_uri.scheme == parsed_uri.scheme and
97-
parsed_allowed_uri.netloc == parsed_uri.netloc and
98-
parsed_allowed_uri.path == parsed_uri.path):
97+
parsed_allowed_uri.netloc == parsed_uri.netloc and
98+
parsed_allowed_uri.path == parsed_uri.path):
9999

100100
aqs_set = set(parse_qsl(parsed_allowed_uri.query))
101101
uqs_set = set(parse_qsl(parsed_uri.query))

oauth2_provider/oauth2_validators.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ def _authenticate_request_body(self, request):
9090
Remember that this method is NOT RECOMMENDED and SHOULD be limited to clients unable to
9191
directly utilize the HTTP Basic authentication scheme. See rfc:`2.3.1` for more details.
9292
"""
93-
#TODO: check if oauthlib has already unquoted client_id and client_secret
93+
# TODO: check if oauthlib has already unquoted client_id and client_secret
9494
client_id = request.client_id
9595
client_secret = request.client_secret
9696

oauth2_provider/tests/test_auth_backends.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ def test_get_user(self):
7676
'oauth2_provider.backends.OAuth2Backend',
7777
'django.contrib.auth.backends.ModelBackend',
7878
),
79-
MIDDLEWARE_CLASSES=MIDDLEWARE_CLASSES+('oauth2_provider.middleware.OAuth2TokenMiddleware',)
79+
MIDDLEWARE_CLASSES=MIDDLEWARE_CLASSES + ('oauth2_provider.middleware.OAuth2TokenMiddleware',)
8080
)
8181
class TestOAuth2Middleware(BaseTest):
8282

oauth2_provider/tests/test_authorization_code.py

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
from ..compat import urlparse, parse_qs, urlencode, get_user_model
1313
from ..models import get_application_model, Grant, AccessToken
1414
from ..settings import oauth2_settings
15-
from ..oauth2_validators import OAuth2Validator
1615
from ..views import ProtectedResourceView
1716

1817
from .test_utils import TestCaseUtils
@@ -35,7 +34,7 @@ def setUp(self):
3534
self.dev_user = UserModel.objects.create_user("dev_user", "[email protected]", "123456")
3635

3736
oauth2_settings.ALLOWED_REDIRECT_URI_SCHEMES = ['http', 'custom-scheme']
38-
37+
3938
self.application = Application(
4039
name="Test Application",
4140
redirect_uris="http://localhost http://example.com http://example.it custom-scheme://example.com",
@@ -74,7 +73,6 @@ def test_skip_authorization_completely(self):
7473
response = self.client.get(url)
7574
self.assertEqual(response.status_code, 302)
7675

77-
7876
def test_pre_auth_invalid_client(self):
7977
"""
8078
Test error for an invalid client_id with response_type: code
@@ -147,11 +145,11 @@ def test_pre_auth_valid_client_custom_redirect_uri_scheme(self):
147145

148146
def test_pre_auth_approval_prompt(self):
149147
"""
150-
148+
TODO
151149
"""
152150
tok = AccessToken.objects.create(user=self.test_user, token='1234567890',
153151
application=self.application,
154-
expires=timezone.now()+datetime.timedelta(days=1),
152+
expires=timezone.now() + datetime.timedelta(days=1),
155153
scope='read write')
156154
self.client.login(username="test_user", password="123456")
157155
query_string = urlencode({
@@ -173,13 +171,13 @@ def test_pre_auth_approval_prompt(self):
173171

174172
def test_pre_auth_approval_prompt_default(self):
175173
"""
176-
174+
TODO
177175
"""
178176
self.assertEqual(oauth2_settings.REQUEST_APPROVAL_PROMPT, 'force')
179177

180178
AccessToken.objects.create(user=self.test_user, token='1234567890',
181179
application=self.application,
182-
expires=timezone.now()+datetime.timedelta(days=1),
180+
expires=timezone.now() + datetime.timedelta(days=1),
183181
scope='read write')
184182
self.client.login(username="test_user", password="123456")
185183
query_string = urlencode({
@@ -195,13 +193,13 @@ def test_pre_auth_approval_prompt_default(self):
195193

196194
def test_pre_auth_approval_prompt_default_override(self):
197195
"""
198-
196+
TODO
199197
"""
200198
oauth2_settings.REQUEST_APPROVAL_PROMPT = 'auto'
201199

202200
AccessToken.objects.create(user=self.test_user, token='1234567890',
203201
application=self.application,
204-
expires=timezone.now()+datetime.timedelta(days=1),
202+
expires=timezone.now() + datetime.timedelta(days=1),
205203
scope='read write')
206204
self.client.login(username="test_user", password="123456")
207205
query_string = urlencode({
@@ -634,7 +632,8 @@ def test_refresh_repeating_requests_non_rotating_tokens(self):
634632
'scope': content['scope'],
635633
}
636634

637-
with mock.patch('oauthlib.oauth2.rfc6749.request_validator.RequestValidator.rotate_refresh_token', return_value=False):
635+
with mock.patch('oauthlib.oauth2.rfc6749.request_validator.RequestValidator.rotate_refresh_token',
636+
return_value=False):
638637
response = self.client.post(reverse('oauth2_provider:token'), data=token_request_data, **auth_headers)
639638
self.assertEqual(response.status_code, 200)
640639
response = self.client.post(reverse('oauth2_provider:token'), data=token_request_data, **auth_headers)
@@ -742,7 +741,7 @@ def test_request_body_params(self):
742741
'code': authorization_code,
743742
'redirect_uri': 'http://example.it',
744743
'client_id': self.application.client_id,
745-
'client_secret': self.application.client_secret,
744+
'client_secret': self.application.client_secret,
746745
}
747746

748747
response = self.client.post(reverse('oauth2_provider:token'), data=token_request_data)

oauth2_provider/tests/test_client_credential.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,10 @@ def test_client_resource_password_based(self):
168168
'username': 'test_user',
169169
'password': '123456'
170170
}
171-
auth_headers = self.get_basic_auth_header(urllib.quote_plus(self.application.client_id), urllib.quote_plus(self.application.client_secret))
171+
auth_headers = self.get_basic_auth_header(
172+
urllib.quote_plus(self.application.client_id),
173+
urllib.quote_plus(self.application.client_secret))
174+
172175
response = self.client.post(reverse('oauth2_provider:token'), data=token_request_data, **auth_headers)
173176
self.assertEqual(response.status_code, 200)
174177

@@ -185,5 +188,3 @@ def test_client_resource_password_based(self):
185188
view = ResourceView.as_view()
186189
response = view(request)
187190
self.assertEqual(response, "This is a protected resource")
188-
189-

oauth2_provider/tests/test_models.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
from django.core.exceptions import ValidationError
1212
from django.utils import timezone
1313

14-
from ..models import AccessToken, get_application_model, Grant, AccessToken, RefreshToken
14+
from ..models import get_application_model, Grant, AccessToken, RefreshToken
1515
from ..compat import get_user_model
1616

1717

@@ -81,6 +81,7 @@ def test_str(self):
8181
app.name = "test_app"
8282
self.assertEqual("%s" % app, "test_app")
8383

84+
8485
@skipIf(django.VERSION < (1, 5), "Behavior is broken on 1.4 and there is no solution")
8586
@override_settings(OAUTH2_PROVIDER_APPLICATION_MODEL='tests.TestApplication')
8687
class TestCustomApplicationModel(TestCase):

0 commit comments

Comments
 (0)