Resolve all django deprecation warnings
This commit is contained in:
parent
91b97fc05f
commit
be5f289a8a
8 changed files with 29 additions and 30 deletions
|
|
@ -51,33 +51,38 @@ class TestAccountSessionHandler(TestCase):
|
|||
"Check count method"
|
||||
self.assertEqual(self.handler.count(), len(self.handler.get()))
|
||||
|
||||
|
||||
class TestDefaultAccount(TestCase):
|
||||
"Check DefaultAccount class"
|
||||
|
||||
def setUp(self):
|
||||
self.s1 = Session()
|
||||
self.s1.puppet = None
|
||||
self.s1.sessid = 0
|
||||
|
||||
|
||||
def test_password_validation(self):
|
||||
"Check password validators deny bad passwords"
|
||||
|
||||
self.account = create.create_account("TestAccount%s" % randint(0, 9), email="test@test.com", password="testpassword", typeclass=DefaultAccount)
|
||||
|
||||
self.account = create.create_account("TestAccount%s" % randint(0, 9),
|
||||
email="test@test.com", password="testpassword", typeclass=DefaultAccount)
|
||||
for bad in ('', '123', 'password', 'TestAccount', '#', 'xyzzy'):
|
||||
self.assertFalse(self.account.validate_password(bad, account=self.account)[0])
|
||||
|
||||
|
||||
"Check validators allow sufficiently complex passwords"
|
||||
for better in ('Mxyzptlk', "j0hn, i'M 0n1y d4nc1nG"):
|
||||
self.assertTrue(self.account.validate_password(better, account=self.account)[0])
|
||||
|
||||
self.account.delete()
|
||||
|
||||
def test_password_change(self):
|
||||
"Check password setting and validation is working as expected"
|
||||
self.account = create.create_account("TestAccount%s" % randint(0, 9), email="test@test.com", password="testpassword", typeclass=DefaultAccount)
|
||||
|
||||
self.account = create.create_account("TestAccount%s" % randint(0, 9),
|
||||
email="test@test.com", password="testpassword", typeclass=DefaultAccount)
|
||||
|
||||
from django.core.exceptions import ValidationError
|
||||
# Try setting some bad passwords
|
||||
for bad in ('', '#', 'TestAccount', 'password'):
|
||||
self.assertRaises(ValidationError, self.account.set_password, bad)
|
||||
|
||||
|
||||
# Try setting a better password (test for False; returns None on success)
|
||||
self.assertFalse(self.account.set_password('Mxyzptlk'))
|
||||
|
||||
|
|
@ -88,7 +93,7 @@ class TestDefaultAccount(TestCase):
|
|||
DefaultAccount().puppet_object(self.s1, None)
|
||||
self.fail("Expected error: 'Object not found'")
|
||||
except RuntimeError as re:
|
||||
self.assertEqual("Object not found", re.message)
|
||||
self.assertEqual("Object not found", str(re))
|
||||
|
||||
def test_puppet_object_no_session(self):
|
||||
"Check puppet_object method called with no session param"
|
||||
|
|
@ -97,7 +102,7 @@ class TestDefaultAccount(TestCase):
|
|||
DefaultAccount().puppet_object(None, Mock())
|
||||
self.fail("Expected error: 'Session not found'")
|
||||
except RuntimeError as re:
|
||||
self.assertEqual("Session not found", re.message)
|
||||
self.assertEqual("Session not found", str(re))
|
||||
|
||||
def test_puppet_object_already_puppeting(self):
|
||||
"Check puppet_object method called, already puppeting this"
|
||||
|
|
@ -180,4 +185,4 @@ class TestDefaultAccount(TestCase):
|
|||
|
||||
account.puppet_object(self.s1, obj)
|
||||
self.assertTrue(self.s1.data_out.call_args[1]['text'].endswith("is already puppeted by another Account."))
|
||||
self.assertIsNone(obj.at_post_puppet.call_args)
|
||||
self.assertIsNone(obj.at_post_puppet.call_args)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue