Made command tests for clothing more robust

I added a lot more test cases to the command tests, ensuring that the system works as intended when given the appropriate arguments (as well as no arguments, as before).
This commit is contained in:
BattleJenkins 2017-04-16 19:45:26 -07:00 committed by Griatch
parent 8da7f45de8
commit 011ba18d5b

View file

@ -460,14 +460,45 @@ from evennia.objects.objects import DefaultRoom
class TestClothingCmd(CommandTest): class TestClothingCmd(CommandTest):
def test_clothingcommands(self): def test_clothingcommands(self):
self.player.contents = [] wearer = create_object(clothing.ClothedCharacter, key="Wearer")
self.call(clothing.CmdWear(), "", "Usage: wear <obj> [wear style]", caller=self.player) friend = create_object(clothing.ClothedCharacter, key="Friend")
self.call(clothing.CmdRemove(), "", "Could not find ''.", caller=self.player) room = create_object(DefaultRoom, key="room")
self.call(clothing.CmdCover(), "", "Usage: cover <worn clothing> [with] <clothing object>", caller=self.player) wearer.location = room
self.call(clothing.CmdUncover(), "", "Usage: uncover <worn clothing object>", caller=self.player) friend.location = room
self.call(clothing.CmdDrop(), "", "Drop what?", caller=self.player) # Make a test hat
self.call(clothing.CmdGive(), "", "Usage: give <inventory object> = <target>", caller=self.player) test_hat = create_object(clothing.Clothing, key="test hat")
self.call(clothing.CmdInventory(), "", "You are not carrying or wearing anything.", caller=self.player) test_hat.db.clothing_type = 'hat'
test_hat.location = wearer
# Make a test scarf
test_scarf = create_object(clothing.Clothing, key="test scarf")
test_scarf.db.clothing_type = 'accessory'
test_scarf.location = wearer
# Test wear command
self.call(clothing.CmdWear(), "", "Usage: wear <obj> [wear style]", caller=wearer)
self.call(clothing.CmdWear(), "hat", "Wearer puts on test hat.", caller=wearer)
self.call(clothing.CmdWear(), "scarf stylishly", "Wearer wears test scarf stylishly.", caller=wearer)
# Test cover command.
self.call(clothing.CmdCover(), "", "Usage: cover <worn clothing> [with] <clothing object>", caller=wearer)
self.call(clothing.CmdCover(), "hat with scarf", "Wearer covers test hat with test scarf.", caller=wearer)
# Test remove command.
self.call(clothing.CmdRemove(), "", "Could not find ''.", caller=wearer)
self.call(clothing.CmdRemove(), "hat", "You have to take off test scarf first.", caller=wearer)
self.call(clothing.CmdRemove(), "scarf", "Wearer removes test scarf, revealing test hat.", caller=wearer)
# Test uncover command.
test_scarf.wear(wearer, True)
test_hat.db.covered_by = test_scarf
self.call(clothing.CmdUncover(), "", "Usage: uncover <worn clothing object>", caller=wearer)
self.call(clothing.CmdUncover(), "hat", "Wearer uncovers test hat.", caller=wearer)
# Test drop command.
test_hat.db.covered_by = test_scarf
self.call(clothing.CmdDrop(), "", "Drop what?", caller=wearer)
self.call(clothing.CmdDrop(), "hat", "You can't drop that because it's covered by test scarf.", caller=wearer)
self.call(clothing.CmdDrop(), "scarf", "You drop test scarf.", caller=wearer)
# Test give command.
self.call(clothing.CmdGive(), "", "Usage: give <inventory object> = <target>", caller=wearer)
self.call(clothing.CmdGive(), "hat = Friend", "Wearer removes test hat.|You give test hat to Friend.", caller=wearer)
# Test inventory command.
self.call(clothing.CmdInventory(), "", "You are not carrying or wearing anything.", caller=wearer)
class TestClothingFunc(EvenniaTest): class TestClothingFunc(EvenniaTest):