def __init__(self, dsn, backend='aorta.backends.mock'): """Initialize a new :class:`Listener` instance. Args: dsn: a string holding a Data Source Name (DSN) identifying the AMQP 1.0 server and channel. backend: indicates the backend to use. May be a string pointing to the module holding the backend, or an actual instance. """ self.__dsn = dsn self.__backend = load(backend) self.__receiver = None #self.__handlers = MessageHandlersProvider() self.__lock = threading.RLock() self.__event = threading.Event() assert isinstance(self.__backend, BaseMessagingBackend)
def test_load_as_instance(self): backend = load(MockMessagingBackend()) self.assertTrue(isinstance(backend, MockMessagingBackend))
def test_load_by_class_name(self): backend = load('aorta.backends.mock.MockMessagingBackend') self.assertTrue(isinstance(backend, MockMessagingBackend))
def test_load_by_module(self): backend = load('aorta.backends.mock') self.assertTrue(isinstance(backend, MockMessagingBackend))