def test_scan(): loop = asyncio.get_event_loop() network = HDMINetwork( MockAdapter([ True, True, False, True, False, True, False, False, False, False, False, False, False, False, False, False, ]), scan_interval=0, loop=loop, ) network._scan_delay = 0 # network._adapter.set_command_callback(network.command_callback) network.init() network.scan() loop.run_until_complete(asyncio.sleep(0.1, loop)) loop.stop() loop.run_forever() assert HDMIDevice(0) in network.devices device = network.get_device(0) assert "Test0" == device.osd_name assert 2 == device.power_status assert HDMIDevice(1) in network.devices device = network.get_device(1) assert "Test1" == device.osd_name assert 2 == device.power_status assert HDMIDevice(2) not in network.devices assert HDMIDevice(3) in network.devices device = network.get_device(3) assert "Test3" == device.osd_name assert 2 == device.power_status for d in network.devices: d.stop() network.stop() loop.stop() loop.run_forever()
def test_devices(): loop = asyncio.get_event_loop() network = HDMINetwork( MockAdapter([ True, True, False, True, False, True, False, False, False, False, False, False, False, False, False, False, ]), scan_interval=0, loop=loop, ) network._scan_delay = 0 # network._adapter.set_command_callback(network.command_callback) network.init() network.scan() loop.run_until_complete(asyncio.sleep(0.1, loop)) loop.stop() loop.run_forever() for i in [0, 1, 3, 5]: assert HDMIDevice(i) in network.devices for i in [2, 4, 6, 7, 8, 9, 10, 11, 12, 13, 14]: assert HDMIDevice(i) not in network.devices for d in network.devices: d.stop() network.stop() loop.stop() loop.run_forever()