mirror of
https://github.com/evennia/evennia.git
synced 2026-03-16 21:06:30 +01:00
add tests for manager search methods
This commit is contained in:
parent
b5c3781b8a
commit
421a93e112
1 changed files with 46 additions and 0 deletions
|
|
@ -247,6 +247,52 @@ class TestObjectManager(BaseEvenniaTest):
|
|||
)
|
||||
self.assertEqual(list(query), [self.char1])
|
||||
|
||||
def test_get_objs_with_key_or_alias(self):
|
||||
query = ObjectDB.objects.get_objs_with_key_or_alias("Char")
|
||||
self.assertEqual(list(query), [self.char1])
|
||||
self.assertEqual(list(query), [self.char1])
|
||||
query = ObjectDB.objects.get_objs_with_key_or_alias(
|
||||
"Char", typeclasses="evennia.objects.objects.DefaultObject"
|
||||
)
|
||||
self.assertFalse(query)
|
||||
query = ObjectDB.objects.get_objs_with_key_or_alias(
|
||||
"Char", candidates=[self.char1, self.char2]
|
||||
)
|
||||
self.assertEqual(list(query), [self.char1])
|
||||
|
||||
self.char1.aliases.add("test alias")
|
||||
query = ObjectDB.objects.get_objs_with_key_or_alias("test alias")
|
||||
self.assertEqual(list(query), [self.char1])
|
||||
|
||||
query = ObjectDB.objects.get_objs_with_key_or_alias("")
|
||||
self.assertFalse(query)
|
||||
query = ObjectDB.objects.get_objs_with_key_or_alias("", exact=False)
|
||||
self.assertEqual(list(query), list(ObjectDB.objects.all()))
|
||||
|
||||
query = ObjectDB.objects.get_objs_with_key_or_alias(
|
||||
"", exact=False, typeclasses="evennia.objects.objects.DefaultCharacter"
|
||||
)
|
||||
self.assertEqual(list(query), [self.char1, self.char2])
|
||||
|
||||
def test_search_object(self):
|
||||
self.char1.tags.add("test tag")
|
||||
self.obj1.tags.add("test tag")
|
||||
|
||||
query = ObjectDB.objects.search_object(
|
||||
"", exact=False, tags=[('test tag', None)]
|
||||
)
|
||||
self.assertEqual(list(query), [self.obj1, self.char1])
|
||||
|
||||
query = ObjectDB.objects.search_object(
|
||||
"Char", tags=[('invalid tag', None)]
|
||||
)
|
||||
self.assertFalse(query)
|
||||
|
||||
query = ObjectDB.objects.search_object(
|
||||
"", exact=False, tags=[('test tag', None)], typeclass="evennia.objects.objects.DefaultCharacter"
|
||||
)
|
||||
self.assertEqual(list(query), [self.char1])
|
||||
|
||||
def test_get_objs_with_attr(self):
|
||||
self.obj1.db.testattr = "testval1"
|
||||
query = ObjectDB.objects.get_objs_with_attr("testattr")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue