def test_load_handlers_duplicate(self): with self.assertRaises(HandlerConfigError): load_handlers({ 'rfxcom.protocol.Status': 'home.collect.logging_handler', Status: 'home.collect.logging_handler', })
def test_load_handlers_wildcard(self): result = load_handlers({ '*': 'home.collect.logging_handler', }) self.assertEqual(result, { '*': logging_handler })
def test_load_handlers_all_objects(self): h = lambda x: x result = load_handlers({ Status: h, }) self.assertEqual(result, { Status: h })
def collect(dev_name=None, callbacks=None): if callbacks is None: callbacks = dict(load_handlers(config.PACKET_HANDLERS)) loop = get_event_loop() try: logger.info("Starting collection from:", dev_name) AsyncioTransport(dev_name, loop, callbacks=callbacks) loop.run_forever() finally: loop.close()
def test_load_handlers_bad_path(self): with self.assertRaises(ImportError): load_handlers({ 'rfxcom.protocol..Status': 'home.collect.logging_handler' })
def test_load_handlers_empty(self): result = load_handlers({}) self.assertEqual(result, {})