def test_packet_split_len_3(): assert utils.packet_split('', '', '') is None assert utils.packet_split('1:2:3:4', '', '') is None assert utils.packet_split('a:2:3:4:5:6:7:8', '', '') is None assert utils.packet_split('1:2:3:4:5:6:7:8', '1:2', '') is None assert utils.packet_split('1:2:3:4:5:6:7:8', '1:2:3', '-1:1') == \ (['1', '2', '3', '4', '5', '6', '7', '8'], ['1', '2', '3'], ['-1', '1'])
def test_packet_split(): assert utils.packet_split('', '') is None assert utils.packet_split('1:2:3:4', '') is None assert utils.packet_split('a:2:3:4:5:6:7', '') is None assert utils.packet_split('1:2:3:4:5:6:7', '1:2') is None assert utils.packet_split('1:2:3:4:5:6:7', '1:2:3') == \ (['1', '2', '3', '4', '5', '6', '7'], ['1', '2', '3'])
def _save_data(qeez_token, packets, sync=False): '''Parses and saves data packets ''' res_dc = {} for packet in packets: packet_len = len(packet) if isinstance(packet, list) and packet_len >= 2: key, val = packet[:2] if packet_len > 2: rst = packet[2] if packet_split(key, val, rst): res_dc[key] = (val, rst) else: if packet_split(key, val): res_dc[key] = val if res_dc: return _save_packets(qeez_token, res_dc, sync=sync) return False
def _save_data(qeez_token, packets): '''Parses and saves data packets ''' res_dc = {} for packet in packets: if isinstance(packet, list) and len(packet) == 2: key, val = packet if packet_split(key, val): res_dc[key] = val if res_dc: _save_packets(qeez_token, res_dc) return True return False