diff --git a/evennia/accounts/tests.py b/evennia/accounts/tests.py index 81ac25c2a3..2cfd9350cb 100644 --- a/evennia/accounts/tests.py +++ b/evennia/accounts/tests.py @@ -6,12 +6,14 @@ from unittest import TestCase from django.test import override_settings from evennia.accounts.accounts import AccountSessionHandler - from evennia.accounts.accounts import DefaultAccount, DefaultGuest from evennia.server.session import Session +from evennia.utils.test_resources import EvenniaTest from evennia.utils import create from evennia.utils.test_resources import EvenniaTest +from django.conf import settings + class TestAccountSessionHandler(TestCase): "Check AccountSessionHandler class" @@ -134,43 +136,30 @@ class TestDefaultAccountAuth(EvenniaTest): result, error = DefaultAccount.validate_username('xx') 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): "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) 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" 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): "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) from django.core.exceptions import ValidationError # Try setting some bad passwords 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) - self.assertFalse(self.account.set_password('Mxyzptlk')) + self.assertFalse(account.set_password('Mxyzptlk')) class TestDefaultAccount(TestCase): "Check DefaultAccount class" @@ -285,18 +274,17 @@ class TestDefaultAccount(TestCase): class TestAccountPuppetDeletion(EvenniaTest): - + @override_settings(MULTISESSION_MODE=2) def test_puppet_deletion(self): # Check for existing chars self.assertFalse(self.account.db._playable_characters, 'Account should not have any chars by default.') - + # Add char1 to account's playable characters self.account.db._playable_characters.append(self.char1) self.assertTrue(self.account.db._playable_characters, 'Char was not added to account.') - + # See what happens when we delete char1. self.char1.delete() # Playable char list should be empty. - self.assertFalse(self.account.db._playable_characters, - 'Playable character list is not empty! %s' % self.account.db._playable_characters) + self.assertFalse(self.account.db._playable_characters, 'Playable character list is not empty! %s' % self.account.db._playable_characters) \ No newline at end of file