async def test_create_devices(self): """Test device creation.""" ipdb = IPDB() failed = False for prod in ipdb: addr = random_address() try: prod.deviceclass( address=addr, cat=prod.cat, subcat=prod.subcat, description=prod.description, model=prod.model, ) # pylint: disable=broad-except except Exception as e: cat = None if prod.cat is None else f"{int(prod.cat):02x}" subcat = None if prod.subcat is None else f"{int(prod.subcat):02x}" _LOGGER.error("Failed with cat %s subcat %s", cat, subcat) _LOGGER.error(e) _LOGGER.debug(traceback.format_exc()) failed = True if failed: assert False
def setUp(self): """Set up the test.""" set_log_levels( logger="debug", logger_pyinsteon="info", logger_messages="info", logger_topics=False, ) _LOGGER.debug("Running setUp") self.record = 0 addr = random_address() self.topics = [ TopicItem( ALL_LINK_RECORD_RESPONSE, fill_rec(0x2E, 0x01, addr.id, 0x02, 0x03, 0x04), 0.2, ), TopicItem( ALL_LINK_RECORD_RESPONSE, fill_rec(0x2E, 0x02, addr.id, 0x02, 0x03, 0x04), 0.2, ), TopicItem( ALL_LINK_RECORD_RESPONSE, fill_rec(0x2E, 0x03, addr.id, 0x02, 0x03, 0x04), 0.2, ), TopicItem( ALL_LINK_RECORD_RESPONSE, fill_rec(0x2E, 0x04, addr.id, 0x02, 0x03, 0x04), 0.2, ), TopicItem( ALL_LINK_RECORD_RESPONSE, fill_rec(0x2E, 0x05, addr.id, 0x02, 0x03, 0x04), 0.2, ), TopicItem( ALL_LINK_RECORD_RESPONSE, fill_rec(0x2E, 0x06, addr.id, 0x02, 0x03, 0x04), 0.2, ), TopicItem( ALL_LINK_RECORD_RESPONSE, fill_rec(0x2E, 0x07, addr.id, 0x02, 0x03, 0x04), 0.2, ), TopicItem( ALL_LINK_RECORD_RESPONSE, fill_rec(0x2E, 0x08, addr.id, 0x02, 0x03, 0x04), 0.2, ), ]
async def test_load_empty(self): """Test loading an empty modem ALDB.""" async with LOCK: mgr = pub.getDefaultTopicMgr() mgr.delTopic(ALL_LINK_RECORD_RESPONSE) aldb = ModemALDB(random_address()) pub.subscribe(send_nak_response, SEND_FIRST_TOPIC) response = await aldb.async_load() _LOGGER.debug("Done LOAD function.") _LOGGER.debug("Status: %s", response.name) assert aldb.is_loaded _LOGGER.debug("ALDB Record Count: %d", len(aldb)) assert len(aldb) == 0 pub.unsubscribe(send_nak_response, SEND_FIRST_TOPIC)
async def test_load_8_records_eeprom(self): """Test loading 8 records into the modem ALDB.""" async with LOCK: mgr = pub.getDefaultTopicMgr() mgr.delTopic(ALL_LINK_RECORD_RESPONSE) pub.subscribe(self.send_eeprom_response, SEND_READ_EEPROM_TOPIC) aldb = ModemALDB(random_address()) aldb.read_write_mode = ReadWriteMode.EEPROM response = await aldb.async_load() await asyncio.sleep(0.01) _LOGGER.debug("Done LOAD function.") _LOGGER.debug("Status: %s", response.name) assert aldb.is_loaded _LOGGER.debug("ALDB Record Count: %d", len(aldb)) assert len(aldb) == 9 # Includes HWM record pub.unsubscribe(self.send_standard_response, SEND_READ_EEPROM_TOPIC)
def setUp(self): """Set up the test.""" set_log_levels( logger="debug", logger_pyinsteon="info", logger_messages="info", logger_topics=False, ) _LOGGER.debug("Running setUp") self.record = 0 addr = random_address() self.topics_standard = [ TopicItem( ALL_LINK_RECORD_RESPONSE, fill_rec(0x2E, 0x01, addr.id, 0x02, 0x03, 0x04), 0.2, ), TopicItem( ALL_LINK_RECORD_RESPONSE, fill_rec(0x2E, 0x02, addr.id, 0x02, 0x03, 0x04), 0.2, ), TopicItem( ALL_LINK_RECORD_RESPONSE, fill_rec(0x2E, 0x03, addr.id, 0x02, 0x03, 0x04), 0.2, ), TopicItem( ALL_LINK_RECORD_RESPONSE, fill_rec(0x2E, 0x04, addr.id, 0x02, 0x03, 0x04), 0.2, ), TopicItem( ALL_LINK_RECORD_RESPONSE, fill_rec(0x2E, 0x05, addr.id, 0x02, 0x03, 0x04), 0.2, ), TopicItem( ALL_LINK_RECORD_RESPONSE, fill_rec(0x2E, 0x06, addr.id, 0x02, 0x03, 0x04), 0.2, ), TopicItem( ALL_LINK_RECORD_RESPONSE, fill_rec(0x2E, 0x07, addr.id, 0x02, 0x03, 0x04), 0.2, ), TopicItem( ALL_LINK_RECORD_RESPONSE, fill_rec(0x2E, 0x08, addr.id, 0x02, 0x03, 0x04), 0.2, ), ] self.topics_eeprom = [ TopicItem( READ_EEPROM_RESPONSE, fill_eeprom_rec(0x1FFF, 0x2E, 0x01, addr.id, 0x02, 0x03, 0x04), 0.2, ), TopicItem( READ_EEPROM_RESPONSE, fill_eeprom_rec(0x1FF7, 0x2E, 0x02, addr.id, 0x02, 0x03, 0x04), 0.2, ), TopicItem( READ_EEPROM_RESPONSE, fill_eeprom_rec(0x1FEF, 0x2E, 0x03, addr.id, 0x02, 0x03, 0x04), 0.2, ), TopicItem( READ_EEPROM_RESPONSE, fill_eeprom_rec(0x1FE7, 0x2E, 0x04, addr.id, 0x02, 0x03, 0x04), 0.2, ), TopicItem( READ_EEPROM_RESPONSE, fill_eeprom_rec(0x1FDF, 0x2E, 0x05, addr.id, 0x02, 0x03, 0x04), 0.2, ), TopicItem( READ_EEPROM_RESPONSE, fill_eeprom_rec(0x1FD7, 0x2E, 0x06, addr.id, 0x02, 0x03, 0x04), 0.2, ), TopicItem( READ_EEPROM_RESPONSE, fill_eeprom_rec(0x1FCF, 0x2E, 0x07, addr.id, 0x02, 0x03, 0x04), 0.2, ), TopicItem( READ_EEPROM_RESPONSE, fill_eeprom_rec(0x1FC7, 0x2E, 0x08, addr.id, 0x02, 0x03, 0x04), 0.2, ), TopicItem( READ_EEPROM_RESPONSE, fill_eeprom_rec(0x1FBF, 0x00, 0x00, Address("000000"), 0x00, 0x00, 0x00), 0.2, ), ]