User.is_authenticated is a property from Django 1.10 and onward

This commit is contained in:
Jaap Roes
2017-03-16 16:03:43 +01:00
parent a5eca5ea4d
commit aa9c4a6063
+8 -2
View File
@@ -6,6 +6,8 @@ except ImportError:
import json import json
import uuid import uuid
import django
from django.contrib.auth.models import User from django.contrib.auth.models import User
from django.db import models from django.db import models
from django.test import TestCase from django.test import TestCase
@@ -73,8 +75,12 @@ class SortableTestCase(TestCase):
return category return category
def test_new_user_is_authenticated(self): def test_new_user_is_authenticated(self):
self.assertEqual(self.user.is_authenticated(), True, if django.VERSION < (1, 10):
'User is not authenticated') self.assertEqual(self.user.is_authenticated(), True,
'User is not authenticated')
else:
self.assertEqual(self.user.is_authenticated, True,
'User is not authenticated')
def test_new_user_is_staff(self): def test_new_user_is_staff(self):
self.assertEqual(self.user.is_staff, True, 'User is not staff') self.assertEqual(self.user.is_staff, True, 'User is not staff')