Merge pull request #2002 from strikaco/creation

Fixes issue where accountless character creation fails (#1921)
This commit is contained in:
Griatch 2019-12-16 19:09:32 +01:00 committed by GitHub
commit d7c1d2bb98
2 changed files with 20 additions and 5 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

@ -9,23 +9,37 @@ class DefaultObjectTest(EvenniaTest):
def test_object_create(self):
description = "A home for a grouch."
home = self.room1.dbref
obj, errors = DefaultObject.create(
"trashcan", self.account, description=description, ip=self.ip
"trashcan", self.account, description=description, ip=self.ip, home=home
)
self.assertTrue(obj, errors)
self.assertFalse(errors, errors)
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(self):
description = "A furry green monster, reeking of garbage."
home = self.room1.dbref
obj, errors = DefaultCharacter.create(
"oscar", self.account, description=description, ip=self.ip
"oscar", self.account, description=description, ip=self.ip, home=home
)
self.assertTrue(obj, errors)
self.assertFalse(errors, errors)
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."