add unit tests

This commit is contained in:
Cal 2025-12-08 22:05:16 -07:00
parent 0d00028374
commit 57b6d35b02

View file

@ -395,6 +395,30 @@ class TestObjectManager(BaseEvenniaTest):
self.assertEqual(self.obj1.attributes.get(key="phrase", category="adventure"), "plugh")
self.assertEqual(obj2.attributes.get(key="phrase", category="adventure"), "plugh")
def test_copy_object_clone_key(self):
# reset key to avoid overlap with other tests
self.obj1.key = "CopyMe"
copied = self.obj1.copy()
self.assertEqual(copied.key, "CopyMe001") # original was Obj
copied2 = self.obj1.copy()
self.assertEqual(copied2.key, "CopyMe002") # next clone
# verify that it increments based on max existing identifier
# both for skipped numbers...
copied.key = "CopyMe003"
copied3 = self.obj1.copy()
self.assertEqual(copied3.key, "CopyMe004")
copied3.delete()
# ...and for duplicate numbers
copied.key = "CopyMe001"
copied2.key = "CopyMe001"
copied3 = self.obj1.copy()
self.assertEqual(copied3.key, "CopyMe002")
def test_copy_object_no_location(self):
self.obj1.location = None
# we just want to make sure this doesn't error
self.assertIsNotNone(self.obj1.copy())
class TestContentHandler(BaseEvenniaTest):
"Test the ContentHandler (obj.contents)"