Fixes create() method failure where no account was provided.

This commit is contained in:
Johnny 2019-12-04 19:18:39 +00:00
parent 45abac71f4
commit 6859b2ac0e
2 changed files with 12 additions and 3 deletions

View file

@ -2076,9 +2076,10 @@ class DefaultCharacter(DefaultObject):
try:
# Check to make sure account does not have too many chars
if len(account.characters) >= settings.MAX_NR_CHARACTERS:
errors.append("There are too many characters associated with this account.")
return obj, errors
if account:
if len(account.characters) >= settings.MAX_NR_CHARACTERS:
errors.append("There are too many characters associated with this account.")
return obj, errors
# Create the Character
obj = create.create_object(**kwargs)

View file

@ -32,6 +32,14 @@ class DefaultObjectTest(EvenniaTest):
self.assertEqual(description, obj.db.desc)
self.assertEqual(obj.db.creator_ip, self.ip)
self.assertEqual(obj.db_home, self.room1)
def test_character_create_noaccount(self):
obj, errors = DefaultCharacter.create(
"oscar", None, home=self.room1.dbref
)
self.assertTrue(obj, errors)
self.assertFalse(errors, errors)
self.assertEqual(obj.db_home, self.room1)
def test_room_create(self):
description = "A dimly-lit alley behind the local Chinese restaurant."