Add searchable

This commit is contained in:
Count Infinity 2025-11-19 00:18:31 -07:00
parent 1c99e89f1c
commit e834e34fd1

View file

@ -1047,18 +1047,19 @@ class TestIssue2908(BaseEvenniaTest):
class TestIssue3824(BaseEvenniaTest): class TestIssue3824(BaseEvenniaTest):
""" """
Test that $obj, $objlist, and $search callables work correctly when spawning prototypes. Test that $obj, $objlist, $search, and $dbref callables work correctly when spawning prototypes.
Regression test for bug where 'prototype' kwarg was passed to search functions causing TypeError.
""" """
def test_spawn_with_search_callables(self): def test_spawn_with_search_callables(self):
"""Test spawning prototype with $obj, $objlist, and $search callables.""" """Test spawning prototype with $obj, $objlist, $search, and $dbref callables."""
# Setup: tag some objects for searching # Setup: tag some objects for searching
self.room1.tags.add("test_location", category="zone") self.room1.tags.add("test_location", category="zone")
self.room2.tags.add("test_location", category="zone") self.room2.tags.add("test_location", category="zone")
self.obj1.tags.add("test_item", category="item_type") self.obj1.tags.add("test_item", category="item_type")
# Create prototype using all three search callables # Create prototype using all search callables
prot = { prot = {
"prototype_key": "test_search_callables", "prototype_key": "test_search_callables",
"typeclass": "evennia.objects.objects.DefaultObject", "typeclass": "evennia.objects.objects.DefaultObject",
@ -1066,6 +1067,7 @@ class TestIssue3824(BaseEvenniaTest):
"attr_obj": f"$obj({self.obj1.dbref})", "attr_obj": f"$obj({self.obj1.dbref})",
"attr_search": "$search(Char)", "attr_search": "$search(Char)",
"attr_objlist": "$objlist(test_location, category=zone, type=tag)", "attr_objlist": "$objlist(test_location, category=zone, type=tag)",
"attr_dbref": f"$dbref({self.obj1.dbref})",
} }
# This should not raise TypeError about 'prototype' kwarg # This should not raise TypeError about 'prototype' kwarg
@ -1077,13 +1079,13 @@ class TestIssue3824(BaseEvenniaTest):
# Verify all search callables worked correctly # Verify all search callables worked correctly
self.assertEqual(obj.db.attr_obj, self.obj1) self.assertEqual(obj.db.attr_obj, self.obj1)
self.assertEqual(obj.db.attr_search, self.char1) self.assertEqual(obj.db.attr_search, self.char1)
self.assertEqual(obj.db.attr_dbref, self.obj1)
# attr_objlist should be a list or list-like object with 2 rooms # attr_objlist should be a list or list-like object with 2 rooms
objlist = obj.db.attr_objlist objlist = obj.db.attr_objlist
self.assertEqual(len(objlist), 2) self.assertEqual(len(objlist), 2)
self.assertIn(self.room1, objlist) self.assertIn(self.room1, objlist)
self.assertIn(self.room2, objlist) self.assertIn(self.room2, objlist)
class TestIssue3101(EvenniaCommandTest): class TestIssue3101(EvenniaCommandTest):
""" """
Spawning and using create_object should store the same `typeclass_path` if using Spawning and using create_object should store the same `typeclass_path` if using