'``StartApplication.run()`` passes environment variables to connect to
the remote application to ``DockerClient.add``.'

def test_links(self):

    fake_docker = FakeDockerClient()
    deployer = ApplicationNodeDeployer(u'example.com', fake_docker)
    application_name = u'site-example.com'
    application = Application(name=application_name, image=DockerImage(repository=u'clusterhq/postgresql', tag=u'9.3.5'), links=frozenset([Link(alias='alias', local_port=80, remote_port=8080)]))
    StartApplication(application=application, node_state=EMPTY_NODESTATE).run(deployer, state_persister=InMemoryStatePersister())
    variables = frozenset({'ALIAS_PORT_80_TCP': 'tcp://example.com:8080', 'ALIAS_PORT_80_TCP_ADDR': 'example.com', 'ALIAS_PORT_80_TCP_PORT': '8080', 'ALIAS_PORT_80_TCP_PROTO': 'tcp'}.iteritems())
    expected_environment = Environment(variables=variables.copy())
    self.assertEqual(expected_environment, fake_docker._units[application_name].environment)
