def test_ip_lookup_invalid_ip(self, ip): from akadata import EdgeScape es = EdgeScape() with pytest.raises(ValueError): es.ip_lookup(ip)
def test_ip_lookup_timeout(self): from contextlib import closing import socket from akadata import EdgeScape with closing(socket.socket(socket.AF_INET, socket.SOCK_DGRAM)) as sock: sock.bind(('localhost', 0)) host, port = sock.getsockname() es = EdgeScape(host, port) with pytest.raises(socket.timeout): es.ip_lookup('192.168.1.1', timeout=0.1)
def test_ip_lookup(self, edgescape_server, ip, resp, parsed_data): from akadata import EdgeScape # ip_lookup() adds the ip address to the parsed data parsed_data['ip'] = ip edgescape_server.responses.append(resp) es = EdgeScape(*edgescape_server.server_address) result = es.ip_lookup(ip) assert result == parsed_data