TaskHandler.remove() made functional
TaskHandler.remove method now functions. Previous it would have removed the task from the TaskHandler.tasks dictionary, but never canceled the task. Making the "remove a persistent task without executing it" incorrect. Previous there was no method to get a persistent tasks's deferral instance, which was likely why TaskHandler.remove was not used within the module. Added unit tests to test TaskHandler.remove
This commit is contained in:
parent
97f7806348
commit
f3b546bcf6
2 changed files with 34 additions and 7 deletions
|
|
@ -351,3 +351,17 @@ class TestDelay(EvenniaTest):
|
|||
_TASK_HANDLER.clock.advance(timedelay) # make time pass
|
||||
self.assertEqual(self.char1.ndb.dummy_var, False)
|
||||
self.char1.ndb.dummy_var = False
|
||||
# test removing an active task
|
||||
task_id = utils.delay(timedelay, dummy_func, self.char1.dbref)
|
||||
success = _TASK_HANDLER.remove(task_id)
|
||||
_TASK_HANDLER.clock.advance(timedelay) # make time pass
|
||||
self.assertEqual(self.char1.ndb.dummy_var, False)
|
||||
self.char1.ndb.dummy_var = False
|
||||
# test removing a canceled active task
|
||||
task_id = utils.delay(timedelay, dummy_func, self.char1.dbref)
|
||||
deferal_inst = _TASK_HANDLER.get_deferred(task_id)
|
||||
deferal_inst.cancel()
|
||||
success = _TASK_HANDLER.remove(task_id)
|
||||
_TASK_HANDLER.clock.advance(timedelay) # make time pass
|
||||
self.assertEqual(self.char1.ndb.dummy_var, False)
|
||||
self.char1.ndb.dummy_var = False
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue