Add a confirmation to the default @destroy command

This commit is contained in:
Vincent Le Goff 2017-09-01 15:41:35 +02:00
parent ac65c9f7ec
commit 64e327fdd2
2 changed files with 61 additions and 14 deletions

View file

@ -13,6 +13,7 @@ main test suite started with
"""
import re
import types
from django.conf import settings
from mock import Mock
@ -73,8 +74,12 @@ class CommandTest(EvenniaTest):
receiver.msg = Mock()
cmdobj.at_pre_cmd()
cmdobj.parse()
cmdobj.func()
ret = cmdobj.func()
if isinstance(ret, types.GeneratorType):
ret.next()
cmdobj.at_post_cmd()
except StopIteration:
pass
except InterruptCommand:
pass
finally:
@ -250,7 +255,10 @@ class TestBuilding(CommandTest):
self.call(building.CmdDesc(), "Obj2=TestDesc", "The description was set on Obj2(#5).")
def test_wipe(self):
confirm = building.CmdDestroy.confirm
building.CmdDestroy.confirm = False
self.call(building.CmdDestroy(), "Obj", "Obj was destroyed.")
building.CmdDestroy.confirm = confirm
def test_dig(self):
self.call(building.CmdDig(), "TestRoom1=testroom;tr,back;b", "Created room TestRoom1")
@ -330,7 +338,10 @@ class TestBatchProcess(CommandTest):
# cannot test batchcode here, it must run inside the server process
self.call(batchprocess.CmdBatchCommands(), "example_batch_cmds", "Running Batchcommand processor Automatic mode for example_batch_cmds")
# we make sure to delete the button again here to stop the running reactor
confirm = building.CmdDestroy.confirm
building.CmdDestroy.confirm = False
self.call(building.CmdDestroy(), "button", "button was destroyed.")
building.CmdDestroy.confirm = confirm
class CmdInterrupt(Command):