def test_create_lookup_key_index_preserves_structure(self): engine_config = SenderConfigSSL( address=(self.server, self.port), key=self.key, cert=self.cert, chain=self.chain, check_hostname=False, verify_mode=CERT_NONE, ) con = Sender(engine_config) lookup = Lookup(name=self.lookup_name, con=con) headers = ["col1", "col2", "col3"] fields = ["a", "b", "c"] expected_headers = '[{"col1":{"type":"str","key":true}},{"col2":{"type":"str"}},{"col3":{"type":"str"}}]' with mock.patch.object(lookup, "send_control", wraps=lookup.send_control) as lookup_spy: lookup.send_headers(headers=headers, key_index=0, event="START", action="FULL") lookup_spy.assert_called_with(action="FULL", event="START", headers=expected_headers) lookup.send_data_line(key_index=0, fields=fields) lookup.send_headers(headers=headers, key_index=0, event="END", action="FULL") lookup_spy.assert_called_with(action="FULL", event="END", headers=expected_headers) con.socket.shutdown(0)
def test_ssl_lookup_simplify(self): engine_config = SenderConfigSSL( address=(self.server, self.port), key=self.key, cert=self.cert, chain=self.chain, check_hostname=False, verify_mode=CERT_NONE, ) con = Sender(engine_config) lookup = Lookup(name=self.lookup_name, historic_tag=None, con=con) lookup.send_headers(headers=["KEY", "HEX", "COLOR"], key="KEY", action="START") if len(con.socket.recv(1000)) == 0: raise Exception("Not msg sent!") lookup.send_data_line(key="11", fields=["11", "HEX12", "COLOR12"]) if len(con.socket.recv(1000)) == 0: raise Exception("Not msg sent!") lookup.send_headers(headers=["KEY", "HEX", "COLOR"], key="KEY", action="END") if len(con.socket.recv(1000)) == 0: raise Exception("Not msg sent!") con.socket.shutdown(0)
def test_ssl_lookup_simplify(self): engine_config = SenderConfigSSL(address=(self.server, self.port), key=self.key, cert=self.cert, chain=self.chain) con = Sender(engine_config) lookup = Lookup(name=self.lookup_name, historic_tag=None, con=con) lookup.send_headers(headers=['KEY', 'HEX', 'COLOR'], key='KEY', action='START') lookup.send_data_line(key="11", fields=["11", "HEX12", "COLOR12"]) lookup.send_headers(headers=['KEY', 'HEX', 'COLOR'], key='KEY', action='END') con.socket.shutdown(0)