Fixes failed unit tests.
This commit is contained in:
parent
30b8519d39
commit
70a21265df
1 changed files with 13 additions and 25 deletions
|
|
@ -6,12 +6,14 @@ from unittest import TestCase
|
||||||
|
|
||||||
from django.test import override_settings
|
from django.test import override_settings
|
||||||
from evennia.accounts.accounts import AccountSessionHandler
|
from evennia.accounts.accounts import AccountSessionHandler
|
||||||
|
|
||||||
from evennia.accounts.accounts import DefaultAccount, DefaultGuest
|
from evennia.accounts.accounts import DefaultAccount, DefaultGuest
|
||||||
from evennia.server.session import Session
|
from evennia.server.session import Session
|
||||||
|
from evennia.utils.test_resources import EvenniaTest
|
||||||
from evennia.utils import create
|
from evennia.utils import create
|
||||||
from evennia.utils.test_resources import EvenniaTest
|
from evennia.utils.test_resources import EvenniaTest
|
||||||
|
|
||||||
|
from django.conf import settings
|
||||||
|
|
||||||
|
|
||||||
class TestAccountSessionHandler(TestCase):
|
class TestAccountSessionHandler(TestCase):
|
||||||
"Check AccountSessionHandler class"
|
"Check AccountSessionHandler class"
|
||||||
|
|
@ -134,43 +136,30 @@ class TestDefaultAccountAuth(EvenniaTest):
|
||||||
result, error = DefaultAccount.validate_username('xx')
|
result, error = DefaultAccount.validate_username('xx')
|
||||||
self.assertFalse(result, "2-character username passed validation.")
|
self.assertFalse(result, "2-character username passed validation.")
|
||||||
|
|
||||||
def test_absolute_url(self):
|
|
||||||
"Get URL for account detail page on website"
|
|
||||||
self.account = create.create_account("TestAccount%s" % randint(100000, 999999),
|
|
||||||
email="test@test.com", password="testpassword", typeclass=DefaultAccount)
|
|
||||||
self.assertTrue(self.account.web_get_detail_url())
|
|
||||||
|
|
||||||
def test_admin_url(self):
|
|
||||||
"Get object's URL for access via Admin pane"
|
|
||||||
self.account = create.create_account("TestAccount%s" % randint(100000, 999999),
|
|
||||||
email="test@test.com", password="testpassword", typeclass=DefaultAccount)
|
|
||||||
self.assertTrue(self.account.web_get_admin_url())
|
|
||||||
self.assertTrue(self.account.web_get_admin_url() != '#')
|
|
||||||
|
|
||||||
def test_password_validation(self):
|
def test_password_validation(self):
|
||||||
"Check password validators deny bad passwords"
|
"Check password validators deny bad passwords"
|
||||||
|
|
||||||
self.account = create.create_account("TestAccount%s" % randint(100000, 999999),
|
account = create.create_account("TestAccount%s" % randint(100000, 999999),
|
||||||
email="test@test.com", password="testpassword", typeclass=DefaultAccount)
|
email="test@test.com", password="testpassword", typeclass=DefaultAccount)
|
||||||
for bad in ('', '123', 'password', 'TestAccount', '#', 'xyzzy'):
|
for bad in ('', '123', 'password', 'TestAccount', '#', 'xyzzy'):
|
||||||
self.assertFalse(self.account.validate_password(bad, account=self.account)[0])
|
self.assertFalse(account.validate_password(bad, account=self.account)[0])
|
||||||
|
|
||||||
"Check validators allow sufficiently complex passwords"
|
"Check validators allow sufficiently complex passwords"
|
||||||
for better in ('Mxyzptlk', "j0hn, i'M 0n1y d4nc1nG"):
|
for better in ('Mxyzptlk', "j0hn, i'M 0n1y d4nc1nG"):
|
||||||
self.assertTrue(self.account.validate_password(better, account=self.account)[0])
|
self.assertTrue(account.validate_password(better, account=self.account)[0])
|
||||||
|
|
||||||
def test_password_change(self):
|
def test_password_change(self):
|
||||||
"Check password setting and validation is working as expected"
|
"Check password setting and validation is working as expected"
|
||||||
self.account = create.create_account("TestAccount%s" % randint(0, 9),
|
account = create.create_account("TestAccount%s" % randint(0, 9),
|
||||||
email="test@test.com", password="testpassword", typeclass=DefaultAccount)
|
email="test@test.com", password="testpassword", typeclass=DefaultAccount)
|
||||||
|
|
||||||
from django.core.exceptions import ValidationError
|
from django.core.exceptions import ValidationError
|
||||||
# Try setting some bad passwords
|
# Try setting some bad passwords
|
||||||
for bad in ('', '#', 'TestAccount', 'password'):
|
for bad in ('', '#', 'TestAccount', 'password'):
|
||||||
self.assertRaises(ValidationError, self.account.set_password, bad)
|
self.assertRaises(ValidationError, account.set_password, bad)
|
||||||
|
|
||||||
# Try setting a better password (test for False; returns None on success)
|
# Try setting a better password (test for False; returns None on success)
|
||||||
self.assertFalse(self.account.set_password('Mxyzptlk'))
|
self.assertFalse(account.set_password('Mxyzptlk'))
|
||||||
|
|
||||||
class TestDefaultAccount(TestCase):
|
class TestDefaultAccount(TestCase):
|
||||||
"Check DefaultAccount class"
|
"Check DefaultAccount class"
|
||||||
|
|
@ -298,5 +287,4 @@ class TestAccountPuppetDeletion(EvenniaTest):
|
||||||
# See what happens when we delete char1.
|
# See what happens when we delete char1.
|
||||||
self.char1.delete()
|
self.char1.delete()
|
||||||
# Playable char list should be empty.
|
# Playable char list should be empty.
|
||||||
self.assertFalse(self.account.db._playable_characters,
|
self.assertFalse(self.account.db._playable_characters, 'Playable character list is not empty! %s' % self.account.db._playable_characters)
|
||||||
'Playable character list is not empty! %s' % self.account.db._playable_characters)
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue