コード例 #1
0
 async def test_one_modem(self):
     """Test only one modem can receive records."""
     mgr = pub.getDefaultTopicMgr()
     topic = mgr.getTopic(ALL_LINK_RECORD_RESPONSE, okIfNone=True)
     
     # Check if there is already one listner. If there is, 
     # then we should still only have one at the end
     if topic:
         listeners = topic.getListeners()
         has_listeners = len(listeners) != 0
     else:
         has_listeners = False
     
     modem_aldb_1 = ModemALDB(random_address())
     modem_aldb_2 = ModemALDB(random_address())
     if has_listeners:
         assert modem_aldb_1._read_manager is None
     else:
         print
         print(modem_aldb_1._read_manager)
         print(modem_aldb_2._read_manager)
         assert modem_aldb_1._read_manager is not None
     assert modem_aldb_2._read_manager is None
     
     topic = mgr.getTopic(ALL_LINK_RECORD_RESPONSE)
     listeners = topic.getListeners()
     assert len(listeners) == 1
     
     
コード例 #2
0
    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)
コード例 #3
0
    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)