def setUp(self): self.lifx = light.LifxInfraredLight( "127.0.0.1", label="LIFX mock", nonblock_delay=0, comm_init=lambda: test_utils.MockSocket(product=test_utils.Product.LIGHT), )
def setUp(self): self.lifx = tile.LifxTile( "127.0.0.1", label="LIFX mock", nonblock_delay=0, comm_init=lambda: test_utils.MockSocket(product=test_utils.Product. TILE), )
def setUp(self): self.mock_socket = test_utils.MockSocket() self.lifx = device_manager.DeviceManager( verbose=True, nonblock_delay=0, comm_init=lambda: self.mock_socket, config_path=CONFIG_PATH, )
def setUp(self): self.port = portpicker.pick_unused_port() self.mock_socket = test_utils.MockSocket() self.lifx_server = server.LifxServer( self.port, device_config_path=DEVICE_CONFIG, process_config_path=PROCESS_CONFIG, comm_init=lambda: self.mock_socket, timeout=5, ) self.lifx_client = client.LifxClient(port=self.port, timeout=5)
def test_packet(self): hsbk = packet.Hsbk(hue=21845, saturation=65535, brightness=65535, kelvin=3500) green = light_messages.SetColor(color=hsbk, duration=1024) comm = packet.UdpSender( ip="127.0.0.1", port=56700, comm=test_utils.MockSocket(), nonblock_delay=0 ) packet_comm = packet.PacketComm(comm) payload_bytes, _ = packet_comm.get_bytes_and_source( payload=green, mac_addr="00:00:00:00:00:00", res_required=False, ack_required=False, sequence=0, source=0, ) # Taken from the green light example lifx_ref = [ 0x31, 0x00, 0x00, 0x34, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x66, 0x00, 0x00, 0x00, 0x00, 0x55, 0x55, 0xFF, 0xFF, 0xFF, 0xFF, 0xAC, 0x0D, 0x00, 0x04, 0x00, 0x00, ] payload_bytes_array = [int(bb) for bb in payload_bytes] self.assertEqual(payload_bytes_array, lifx_ref) # Test the full encode-send-receive-decode chain responses = packet_comm.send_recv( payload=green, mac_addr="00:00:00:00:00:00", res_required=True, ack_required=False, sequence=123, source=1234, verbose=True, ) self.assertEqual(len(responses), 1) response = responses.pop() self.assertEqual(response.addr, ("127.0.0.1", packet.LIFX_PORT)) self.assertEqual(response.frame["source"], 1234) self.assertEqual(response.frame_address["sequence"], 123) self.assertEqual(response.protocol_header["type"], light_messages.State.type) self.assertEqual(response.payload["color"], hsbk)
def setUp(self): self.lifx = device.LifxDevice( "127.0.0.1", nonblock_delay=0, comm_init=lambda: test_utils.MockSocket(), )