'``AgentService.get_deployer`` finds a factory the configured backend in
its ``deployers`` dictionary and uses it to create the new
``IDeployer`` provider with the supplied API object and the local
host\'s external IP address and unique node identifier.'

def test_backend_selection(self):

    ip = '192.0.2.7'
    ips = {(self.agent_service.control_service_host, self.agent_service.control_service_port): ip}
    class Deployer(PClass, ):
        api = field(mandatory=True)
        hostname = field(mandatory=True)
        node_uuid = field(mandatory=True)
    class WrongDeployer(PClass, ):
        pass
    def get_external_ip(host, port):
        return ips[(host, port)]
    agent_service = self.agent_service.set('get_external_ip', get_external_ip).set('backend_description', BackendDescription(name=u'foo', needs_reactor=False, needs_cluster_id=False, api_factory=None, deployer_type=DeployerType.p2p)).set('deployers', {DeployerType.p2p: Deployer, DeployerType.block: WrongDeployer})
    api = object()
    deployer = agent_service.get_deployer(api)
    self.assertEqual(Deployer(api=api, hostname=ip, node_uuid=self.ca_set.node.uuid), deployer)
