def test_get_tcp_dstip(): sock = Mock() sock.getsockopt.return_value = struct.pack( '!HHBBBB', socket.ntohs(AF_INET), 1024, 127, 0, 0, 1) method = get_method('nat') assert method.get_tcp_dstip(sock) == ('127.0.0.1', 1024) assert sock.mock_calls == [call.getsockopt(0, 80, 16)]
def test_get_tcp_dstip(): sock = Mock() sock.getsockopt.return_value = struct.pack("!HHBBBB", socket.ntohs(socket.AF_INET), 1024, 127, 0, 0, 1) method = get_method("nat") assert method.get_tcp_dstip(sock) == ("127.0.0.1", 1024) assert sock.mock_calls == [call.getsockopt(0, 80, 16)]