def test_location_handles_reused(instance, monkeypatch, grpc_server_registry):
    '\n    verifies that only one repository location is created when two queued runs from the same\n    location are dequeued in the same iteration\n    '
    create_run(instance, run_id='queued-run', status=PipelineRunStatus.QUEUED)
    create_run(instance, run_id='queued-run-2', status=PipelineRunStatus.QUEUED)
    original_method = GrpcServerRepositoryLocationHandle.__init__
    method_calls = []

    def mocked_handle_init(self, origin, host=None, port=None, socket=None, server_id=None, heartbeat=False, watch_server=True):
        method_calls.append(origin)
        return original_method(self, origin, host, port, socket, server_id, heartbeat, watch_server)
    monkeypatch.setattr(GrpcServerRepositoryLocationHandle, '__init__', mocked_handle_init)
    coordinator = QueuedRunCoordinatorDaemon(interval_seconds=5, max_concurrent_runs=10)
    list(coordinator.run_iteration(instance, grpc_server_registry))
    assert (get_run_ids(instance.run_launcher.queue()) == ['queued-run', 'queued-run-2'])
    assert (len(method_calls) == 1)
verifies that only one repository location is created when two queued runs from the same
location are dequeued in the same iteration
def test_location_handles_reused(instance, monkeypatch, grpc_server_registry):
    '\n    verifies that only one repository location is created when two queued runs from the same\n    location are dequeued in the same iteration\n    '
    create_run(instance, run_id='queued-run', status=PipelineRunStatus.QUEUED)
    create_run(instance, run_id='queued-run-2', status=PipelineRunStatus.QUEUED)
    original_method = GrpcServerRepositoryLocationHandle.__init__
    method_calls = []

    def mocked_handle_init(self, origin, host=None, port=None, socket=None, server_id=None, heartbeat=False, watch_server=True):
        method_calls.append(origin)
        return original_method(self, origin, host, port, socket, server_id, heartbeat, watch_server)
    monkeypatch.setattr(GrpcServerRepositoryLocationHandle, '__init__', mocked_handle_init)
    coordinator = QueuedRunCoordinatorDaemon(interval_seconds=5, max_concurrent_runs=10)
    list(coordinator.run_iteration(instance, grpc_server_registry))
    assert (get_run_ids(instance.run_launcher.queue()) == ['queued-run', 'queued-run-2'])
    assert (len(method_calls) == 1)