def test_least_connections(): backend1 = Server('localhost:8081') backend1.open_connections = 10 backend2 = Server('localhost:8082') backend2.open_connections = 5 backend3 = Server('localhost:8083') backend3.open_connections = 2 servers = [backend1, backend2, backend3] result = least_connections(servers) assert result == backend3
def test_least_connections_empty_list(): result = least_connections([]) assert result == None