Merge pull request #2002 from strikaco/creation
Fixes issue where accountless character creation fails (#1921)
This commit is contained in:
commit
d7c1d2bb98
2 changed files with 20 additions and 5 deletions
|
|
@ -2076,9 +2076,10 @@ class DefaultCharacter(DefaultObject):
|
||||||
|
|
||||||
try:
|
try:
|
||||||
# Check to make sure account does not have too many chars
|
# Check to make sure account does not have too many chars
|
||||||
if len(account.characters) >= settings.MAX_NR_CHARACTERS:
|
if account:
|
||||||
errors.append("There are too many characters associated with this account.")
|
if len(account.characters) >= settings.MAX_NR_CHARACTERS:
|
||||||
return obj, errors
|
errors.append("There are too many characters associated with this account.")
|
||||||
|
return obj, errors
|
||||||
|
|
||||||
# Create the Character
|
# Create the Character
|
||||||
obj = create.create_object(**kwargs)
|
obj = create.create_object(**kwargs)
|
||||||
|
|
|
||||||
|
|
@ -9,23 +9,37 @@ class DefaultObjectTest(EvenniaTest):
|
||||||
|
|
||||||
def test_object_create(self):
|
def test_object_create(self):
|
||||||
description = "A home for a grouch."
|
description = "A home for a grouch."
|
||||||
|
home = self.room1.dbref
|
||||||
|
|
||||||
obj, errors = DefaultObject.create(
|
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.assertTrue(obj, errors)
|
||||||
self.assertFalse(errors, errors)
|
self.assertFalse(errors, errors)
|
||||||
self.assertEqual(description, obj.db.desc)
|
self.assertEqual(description, obj.db.desc)
|
||||||
self.assertEqual(obj.db.creator_ip, self.ip)
|
self.assertEqual(obj.db.creator_ip, self.ip)
|
||||||
|
self.assertEqual(obj.db_home, self.room1)
|
||||||
|
|
||||||
def test_character_create(self):
|
def test_character_create(self):
|
||||||
description = "A furry green monster, reeking of garbage."
|
description = "A furry green monster, reeking of garbage."
|
||||||
|
home = self.room1.dbref
|
||||||
|
|
||||||
obj, errors = DefaultCharacter.create(
|
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.assertTrue(obj, errors)
|
||||||
self.assertFalse(errors, errors)
|
self.assertFalse(errors, errors)
|
||||||
self.assertEqual(description, obj.db.desc)
|
self.assertEqual(description, obj.db.desc)
|
||||||
self.assertEqual(obj.db.creator_ip, self.ip)
|
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):
|
def test_room_create(self):
|
||||||
description = "A dimly-lit alley behind the local Chinese restaurant."
|
description = "A dimly-lit alley behind the local Chinese restaurant."
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue