def test_macro_command_send_notification(): class TestCommand(SimpleCommand): def execute(self, note): self.facade.send_notification('TEST_NOTIFICATION') class TestMacroCommand(MacroCommand): def initialize_macro_command(self): self.sub_commands.append(TestCommand) class TestMediator(Mediator): _test_var = None def list_notification_interests(self): return ['TEST_NOTIFICATION'] def handle_notification(self, note): if note.get_name() == 'TEST_NOTIFICATION': self._test_var = 10 facade = Facade('test_command_send_notification') facade.register_command('COMMAND', TestMacroCommand) facade.register_mediator(TestMediator()) facade.send_notification('COMMAND') eq_(facade.retrieve_mediator('TestMediator')._test_var, 10)
def testRegisterCommandAndSendNotification(): """FacadeTest: Test register_command() and send_notification()""" fcde = Facade('test') fcde.register_command('FacadeTestNote', utils.facade.FacadeTestCommand) vo = utils.facade.FacadeTestVO(32) fcde.send_notification('FacadeTestNote', vo) eq_(vo.result, 64)
def testRegisterAndRemoveCommandAndSendNotification(): """FacadeTest: Test remove_command() and subsequent send_notification()""" fcde = Facade('test') fcde.register_command('FacadeTestNote', utils.facade.FacadeTestCommand) fcde.remove_command('FacadeTestNote') vo = utils.facade.FacadeTestVO(32) fcde.send_notification('FacadeTestNote', vo) ok_(vo.result != 64)