Ejemplo n.º 1
0
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)
Ejemplo n.º 2
0
def testRegisterAndRemoveProxy():
    """FacadeTest: Test register_proxy() and remove_proxy()"""
    fcde = Facade('test')
    pxy = Proxy('sizes', ['7', '13', '21'])
    fcde.register_proxy(pxy)

    removedProxy = fcde.remove_proxy('sizes')
    eq_(removedProxy.get_proxy_name(), 'sizes')

    pxy = fcde.retrieve_proxy('sizes')
    ok_(pxy is None)
Ejemplo n.º 3
0
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)
Ejemplo n.º 4
0
def testRegisterAndRetrieveProxy():
    """FacadeTest: Test register_proxy() and retrieve_proxy()"""
    fcde = Facade('test')
    fcde.register_proxy(Proxy('colors', ['red', 'green', 'blue']))
    pxy = fcde.retrieve_proxy('colors')

    ok_(isinstance(pxy, IProxy))

    data = pxy.get_data()

    ok_(data is not None)
    ok_(isinstance(data, list))
    eq_(len(data), 3)
    eq_(data[0], 'red')
    eq_(data[1], 'green')
    eq_(data[2], 'blue')
Ejemplo n.º 5
0
def testHasMediator():
    """FacadeTest: Test has_mediator()"""
    fcde = Facade('test')
    fcde.register_mediator(Mediator('facadeHasMediatorTest', object()))
    ok_(fcde.has_mediator('facadeHasMediatorTest'))

    fcde.remove_mediator('facadeHasMediatorTest')
    ok_(not fcde.has_mediator('facadeHasMediatorTest'))
Ejemplo n.º 6
0
def testHasProxy():
    """FacadeTest: Test has_proxy()"""
    fcde = Facade('test')
    fcde.register_proxy(Proxy('hasProxyTest', [1,2,3]))
    ok_(fcde.has_proxy('hasProxyTest'))

    fcde.remove_proxy('hasProxyTest')
    ok_(not fcde.has_proxy('hasProxyTest'))
Ejemplo n.º 7
0
def testHasCommand():
    """FacadeTest: Test has_command()"""
    fcde = Facade('test')
    fcde.register_command('facadeHasCommandTest', utils.facade.FacadeTestCommand)
    ok_(fcde.has_command('facadeHasCommandTest'))

    fcde.remove_command('facadeHasCommandTest')
    ok_(not fcde.has_command('facadeHasCommandTest'))
Ejemplo n.º 8
0
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)
Ejemplo n.º 9
0
def testRegisterRetrieveAndRemoveMediator():
    """FacadeTest: Test register_mediator() retrieve_mediator() and remove_mediator()"""
    fcde = Facade('test')
    fcde.register_mediator(Mediator(view_component=object()))
    ok_(fcde.retrieve_mediator('Mediator') is not None)

    removedMediator = fcde.remove_mediator('Mediator')
    eq_(removedMediator.get_mediator_name(), 'Mediator')
    ok_(fcde.retrieve_mediator(Mediator.NAME) is None)
Ejemplo n.º 10
0
def test_register_retrieve_and_remove_proxy():
    """FacadeTest: Test register_proxy() and remove_proxy()"""
    facade = Facade("test_register_retrieve_and_remove_proxy")

    facade.register_proxy(CustomProxy())

    proxy = facade.retrieve_proxy("CustomProxy")
    eq_(proxy.get_data(), 5)

    removedProxy = facade.remove_proxy("CustomProxy")
    eq_(removedProxy.get_proxy_name(), "CustomProxy")

    proxy = facade.retrieve_proxy("CustomProxy")
    ok_(proxy is None)