#NEWLINE# def test_discover_application_with_environment_and_links( self ) : #NEWLINE# #INDENT# '\n        An ``Application`` with ``Environment`` and ``Link`` objects is\n        discovered from a ``Unit`` with both custom environment variables and\n        environment variables representing container links. The environment\n        variables taking the format <ALIAS>_PORT_<PORT>_TCP are separated in\n        to ``Link`` representations in the ``Application``.\n        ' #NEWLINE# environment_variables = ( ( b'CUSTOM_ENV_A' , b'a value' ) , ( b'CUSTOM_ENV_B' , b'something else' ) ) #NEWLINE# link_environment_variables = ( ( b'APACHE_PORT_80_TCP' , b'tcp://example.com:8080' ) , ( b'APACHE_PORT_80_TCP_PROTO' , b'tcp' ) , ( b'APACHE_PORT_80_TCP_ADDR' , b'example.com' ) , ( b'APACHE_PORT_80_TCP_PORT' , b'8080' ) ) #NEWLINE# unit_environment = ( environment_variables + link_environment_variables ) #NEWLINE# environment = Environment ( variables = frozenset ( unit_environment ) ) #NEWLINE# unit1 = UNIT_FOR_APP . set ( 'environment' , environment ) #NEWLINE# units = { #NEWLINE# #INDENT# unit1 . name : unit1 , #NEWLINE# #UNINDENT# } #NEWLINE# links = [ Link ( local_port = 80 , remote_port = 8080 , alias = 'APACHE' ) ] #NEWLINE# applications = [ APP . set ( 'links' , links ) . set ( 'environment' , dict ( environment_variables ) ) ] #NEWLINE# self . _verify_discover_state_applications ( units , environment_variables )