few flake8 and python3 problems corrected
This commit is contained in:
parent
b6cffcf482
commit
3063cf116b
@ -18,7 +18,6 @@ from django.contrib import messages
|
|||||||
from django.utils.translation import ugettext_lazy as _
|
from django.utils.translation import ugettext_lazy as _
|
||||||
from django.utils import timezone
|
from django.utils import timezone
|
||||||
from django.utils.encoding import python_2_unicode_compatible
|
from django.utils.encoding import python_2_unicode_compatible
|
||||||
from django.core.exceptions import ValidationError
|
|
||||||
from django.core.mail import send_mail
|
from django.core.mail import send_mail
|
||||||
|
|
||||||
import re
|
import re
|
||||||
|
@ -81,6 +81,7 @@ class FederatedUserTestCase(TestCase, UserModels, FederatedIendityProviderModel)
|
|||||||
self.assertIsNone(user._attributs)
|
self.assertIsNone(user._attributs)
|
||||||
self.assertIsNone(user.attributs)
|
self.assertIsNone(user.attributs)
|
||||||
|
|
||||||
|
|
||||||
class FederateSLOTestCase(TestCase, UserModels):
|
class FederateSLOTestCase(TestCase, UserModels):
|
||||||
"""test for the federated SLO model"""
|
"""test for the federated SLO model"""
|
||||||
def test_clean_deleted_sessions(self):
|
def test_clean_deleted_sessions(self):
|
||||||
@ -275,7 +276,7 @@ class TicketTestCase(TestCase, UserModels, BaseServicePattern):
|
|||||||
self.assertIsNone(ticket.attributs)
|
self.assertIsNone(ticket.attributs)
|
||||||
|
|
||||||
|
|
||||||
@mock.patch("cas_server.utils.last_version", lambda:"1.2.3")
|
@mock.patch("cas_server.utils.last_version", lambda: "1.2.3")
|
||||||
@override_settings(ADMINS=[("Ano Nymous", "ano.nymous@example.net")])
|
@override_settings(ADMINS=[("Ano Nymous", "ano.nymous@example.net")])
|
||||||
@override_settings(CAS_NEW_VERSION_EMAIL_WARNING=True)
|
@override_settings(CAS_NEW_VERSION_EMAIL_WARNING=True)
|
||||||
class NewVersionWarningTestCase(TestCase):
|
class NewVersionWarningTestCase(TestCase):
|
||||||
|
@ -49,7 +49,7 @@ class LoginTestCase(TestCase, BaseServicePattern, CanLogin):
|
|||||||
self.setup_service_patterns()
|
self.setup_service_patterns()
|
||||||
|
|
||||||
@override_settings(CAS_NEW_VERSION_HTML_WARNING=True)
|
@override_settings(CAS_NEW_VERSION_HTML_WARNING=True)
|
||||||
@mock.patch("cas_server.utils.last_version", lambda:"1.2.3")
|
@mock.patch("cas_server.utils.last_version", lambda: "1.2.3")
|
||||||
@mock.patch("cas_server.utils.VERSION", "0.1.2")
|
@mock.patch("cas_server.utils.VERSION", "0.1.2")
|
||||||
def test_new_version_available_ok(self):
|
def test_new_version_available_ok(self):
|
||||||
client = Client()
|
client = Client()
|
||||||
@ -57,7 +57,7 @@ class LoginTestCase(TestCase, BaseServicePattern, CanLogin):
|
|||||||
self.assertIn(b"A new version of the application is available", response.content)
|
self.assertIn(b"A new version of the application is available", response.content)
|
||||||
|
|
||||||
@override_settings(CAS_NEW_VERSION_HTML_WARNING=True)
|
@override_settings(CAS_NEW_VERSION_HTML_WARNING=True)
|
||||||
@mock.patch("cas_server.utils.last_version", lambda:None)
|
@mock.patch("cas_server.utils.last_version", lambda: None)
|
||||||
@mock.patch("cas_server.utils.VERSION", "0.1.2")
|
@mock.patch("cas_server.utils.VERSION", "0.1.2")
|
||||||
def test_new_version_available_badpypi(self):
|
def test_new_version_available_badpypi(self):
|
||||||
client = Client()
|
client = Client()
|
||||||
|
@ -16,10 +16,6 @@ import django
|
|||||||
from django.test import Client
|
from django.test import Client
|
||||||
from django.template import loader
|
from django.template import loader
|
||||||
from django.utils import timezone
|
from django.utils import timezone
|
||||||
if django.VERSION < (1, 8):
|
|
||||||
from django.template import Context
|
|
||||||
else:
|
|
||||||
Context = lambda x:x
|
|
||||||
|
|
||||||
import cgi
|
import cgi
|
||||||
import six
|
import six
|
||||||
@ -33,6 +29,13 @@ from cas_server import models
|
|||||||
from cas_server import utils
|
from cas_server import utils
|
||||||
|
|
||||||
|
|
||||||
|
if django.VERSION < (1, 8):
|
||||||
|
from django.template import Context
|
||||||
|
else:
|
||||||
|
def Context(arg):
|
||||||
|
return arg
|
||||||
|
|
||||||
|
|
||||||
def return_unicode(string, charset):
|
def return_unicode(string, charset):
|
||||||
"""make `string` a unicode if `string` is a unicode or bytes encoded with `charset`"""
|
"""make `string` a unicode if `string` is a unicode or bytes encoded with `charset`"""
|
||||||
if not isinstance(string, six.text_type):
|
if not isinstance(string, six.text_type):
|
||||||
|
@ -654,8 +654,8 @@ def last_version():
|
|||||||
else:
|
else:
|
||||||
try:
|
try:
|
||||||
req = requests.get(settings.CAS_NEW_VERSION_JSON_URL)
|
req = requests.get(settings.CAS_NEW_VERSION_JSON_URL)
|
||||||
data = json.loads(req.content)
|
data = json.loads(req.text)
|
||||||
versions = data["releases"].keys()
|
versions = list(data["releases"].keys())
|
||||||
versions.sort()
|
versions.sort()
|
||||||
version = versions[-1]
|
version = versions[-1]
|
||||||
last_version._cache = (time.time(), version, True)
|
last_version._cache = (time.time(), version, True)
|
||||||
@ -664,7 +664,7 @@ def last_version():
|
|||||||
KeyError,
|
KeyError,
|
||||||
ValueError,
|
ValueError,
|
||||||
requests.exceptions.RequestException
|
requests.exceptions.RequestException
|
||||||
) as error: # pragma: no cover (should not happen unless pypi is not available)
|
) as error: # pragma: no cover (should not happen unless pypi is not available)
|
||||||
logger.error(
|
logger.error(
|
||||||
"Unable to fetch %s: %s" % (settings.CAS_NEW_VERSION_JSON_URL, error)
|
"Unable to fetch %s: %s" % (settings.CAS_NEW_VERSION_JSON_URL, error)
|
||||||
)
|
)
|
||||||
|
Loading…
Reference in New Issue
Block a user