mirror of
https://github.com/evennia/evennia.git
synced 2026-03-17 05:16:31 +01:00
Fix bug in unittest that would cause occational name collision
This commit is contained in:
parent
68ff0ac9d6
commit
fe14dfddef
4 changed files with 24 additions and 8 deletions
|
|
@ -14,9 +14,15 @@ class TestAccountSessionHandler(TestCase):
|
|||
"Check AccountSessionHandler class"
|
||||
|
||||
def setUp(self):
|
||||
self.account = create.create_account("TestAccount%s" % randint(0, 999999), email="test@test.com", password="testpassword", typeclass=DefaultAccount)
|
||||
self.account = create.create_account(
|
||||
"TestAccount%s" % randint(0, 999999), email="test@test.com",
|
||||
password="testpassword", typeclass=DefaultAccount)
|
||||
self.handler = AccountSessionHandler(self.account)
|
||||
|
||||
def tearDown(self):
|
||||
if hasattr(self, 'account'):
|
||||
self.account.delete()
|
||||
|
||||
def test_get(self):
|
||||
"Check get method"
|
||||
self.assertEqual(self.handler.get(), [])
|
||||
|
|
@ -60,6 +66,10 @@ class TestDefaultAccount(TestCase):
|
|||
self.s1.puppet = None
|
||||
self.s1.sessid = 0
|
||||
|
||||
def tearDown(self):
|
||||
if hasattr(self, "account"):
|
||||
self.account.delete()
|
||||
|
||||
def test_password_validation(self):
|
||||
"Check password validators deny bad passwords"
|
||||
|
||||
|
|
@ -71,7 +81,6 @@ class TestDefaultAccount(TestCase):
|
|||
"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.account.delete()
|
||||
|
||||
def test_password_change(self):
|
||||
"Check password setting and validation is working as expected"
|
||||
|
|
@ -109,7 +118,9 @@ class TestDefaultAccount(TestCase):
|
|||
|
||||
import evennia.server.sessionhandler
|
||||
|
||||
account = create.create_account("TestAccount%s" % randint(0, 999999), email="test@test.com", password="testpassword", typeclass=DefaultAccount)
|
||||
account = create.create_account(
|
||||
"TestAccount%s" % randint(0, 999999), email="test@test.com",
|
||||
password="testpassword", typeclass=DefaultAccount)
|
||||
self.s1.uid = account.uid
|
||||
evennia.server.sessionhandler.SESSIONS[self.s1.uid] = self.s1
|
||||
|
||||
|
|
@ -171,6 +182,7 @@ class TestDefaultAccount(TestCase):
|
|||
import evennia.server.sessionhandler
|
||||
|
||||
account = create.create_account("TestAccount%s" % randint(0, 999999), email="test@test.com", password="testpassword", typeclass=DefaultAccount)
|
||||
self.account = account
|
||||
self.s1.uid = account.uid
|
||||
evennia.server.sessionhandler.SESSIONS[self.s1.uid] = self.s1
|
||||
|
||||
|
|
|
|||
|
|
@ -259,11 +259,11 @@ def prototype_from_object(obj):
|
|||
if aliases:
|
||||
prot['aliases'] = aliases
|
||||
tags = [(tag.db_key, tag.db_category, tag.db_data)
|
||||
for tag in obj.tags.get(return_tagobj=True, return_list=True) if tag]
|
||||
for tag in obj.tags.all(return_objs=True)]
|
||||
if tags:
|
||||
prot['tags'] = tags
|
||||
attrs = [(attr.key, attr.value, attr.category, ';'.join(attr.locks.all()))
|
||||
for attr in obj.attributes.get(return_obj=True, return_list=True) if attr]
|
||||
for attr in obj.attributes.all()]
|
||||
if attrs:
|
||||
prot['attrs'] = attrs
|
||||
|
||||
|
|
@ -660,6 +660,7 @@ def spawn(*prototypes, **kwargs):
|
|||
protparents = {prot['prototype_key'].lower(): prot for prot in protlib.search_prototype()}
|
||||
|
||||
if not kwargs.get("only_validate"):
|
||||
# homogenization to be more lenient about prototype format when entering the prototype manually
|
||||
prototypes = [protlib.homogenize_prototype(prot) for prot in prototypes]
|
||||
|
||||
# overload module's protparents with specifically given protparents
|
||||
|
|
@ -714,7 +715,7 @@ def spawn(*prototypes, **kwargs):
|
|||
|
||||
val = prot.pop("tags", [])
|
||||
tags = []
|
||||
for (tag, category, data) in tags:
|
||||
for (tag, category, data) in val:
|
||||
tags.append((init_spawn_value(val, str), category, data))
|
||||
|
||||
prototype_key = prototype.get('prototype_key', None)
|
||||
|
|
|
|||
|
|
@ -668,7 +668,7 @@ class AttributeHandler(object):
|
|||
|
||||
def all(self, accessing_obj=None, default_access=True):
|
||||
"""
|
||||
Return all Attribute objects on this object.
|
||||
Return all Attribute objects on this object, regardless of category.
|
||||
|
||||
Args:
|
||||
accessing_obj (object, optional): Check the `attrread`
|
||||
|
|
|
|||
|
|
@ -345,13 +345,14 @@ class TagHandler(object):
|
|||
self._catcache = {}
|
||||
self._cache_complete = False
|
||||
|
||||
def all(self, return_key_and_category=False):
|
||||
def all(self, return_key_and_category=False, return_objs=False):
|
||||
"""
|
||||
Get all tags in this handler, regardless of category.
|
||||
|
||||
Args:
|
||||
return_key_and_category (bool, optional): Return a list of
|
||||
tuples `[(key, category), ...]`.
|
||||
return_objs (bool, optional): Return tag objects.
|
||||
|
||||
Returns:
|
||||
tags (list): A list of tag keys `[tagkey, tagkey, ...]` or
|
||||
|
|
@ -365,6 +366,8 @@ class TagHandler(object):
|
|||
if return_key_and_category:
|
||||
# return tuple (key, category)
|
||||
return [(to_str(tag.db_key), to_str(tag.db_category)) for tag in tags]
|
||||
elif return_objs:
|
||||
return tags
|
||||
else:
|
||||
return [to_str(tag.db_key) for tag in tags]
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue