def lighting_encode_decode_client_test(): "self-made tests of encode then decode, with packets from a client." orig = PointToMultipointPacket(application=APP_LIGHTING) orig.sal.append(LightingOnSAL(orig, 27)) data = orig.encode() d, r = decode_packet(data, server_packet=False) assert isinstance(orig, PointToMultipointPacket) assert len(orig.sal) == len(d.sal) assert isinstance(d.sal[0], LightingOnSAL) assert orig.sal[0].group_address == d.sal[0].group_address # ensure there is no remaining data to be parsed assert r == None
def lighting_encode_decode_client_test(): "self-made tests of encode then decode, with packets from a client." orig = PointToMultipointPacket(application=APP_LIGHTING) orig.sal.append(LightingOnSAL(orig, 27)) data = orig.encode() d, r = decode_packet(data, server_packet=False) assert isinstance(orig, PointToMultipointPacket) assert len(orig.sal) == len(d.sal) assert isinstance(d.sal[0], LightingOnSAL) assert orig.sal[0].group_address == d.sal[0].group_address # ensure there is no remaining data to be parsed assert r == None
def temperature_encode_decode_test(): "self-made tests of encode then decode" orig = PointToMultipointPacket(application=APP_TEMPERATURE) orig.source_address = 5 orig.sal.append(TemperatureBroadcastSAL(orig, 10, 0.5)) orig.sal.append(TemperatureBroadcastSAL(orig, 11, 56)) data = orig.encode() d, r = decode_packet(data) assert isinstance(orig, PointToMultipointPacket) assert orig.source_address == d.source_address assert len(orig.sal) == len(d.sal) for x in range(len(d.sal)): assert isinstance(d.sal[x], TemperatureBroadcastSAL) assert orig.sal[x].group_address == d.sal[x].group_address assert orig.sal[x].temperature == d.sal[x].temperature # ensure there is no remaining data to be parsed assert r == None
def temperature_encode_decode_test(): "self-made tests of encode then decode" orig = PointToMultipointPacket(application=APP_TEMPERATURE) orig.source_address = 5 orig.sal.append(TemperatureBroadcastSAL(orig, 10, 0.5)) orig.sal.append(TemperatureBroadcastSAL(orig, 11, 56)) data = orig.encode() d, r = decode_packet(data) assert isinstance(orig, PointToMultipointPacket) assert orig.source_address == d.source_address assert len(orig.sal) == len(d.sal) for x in range(len(d.sal)): assert isinstance(d.sal[x], TemperatureBroadcastSAL) assert orig.sal[x].group_address == d.sal[x].group_address assert orig.sal[x].temperature == d.sal[x].temperature # ensure there is no remaining data to be parsed assert r == None