#NEWLINE# def test_format_marathon_app_dict_with_smartstack( ) : #NEWLINE# #INDENT# service = 'service' #NEWLINE# instance = 'instance' #NEWLINE# fake_job_id = 'service.instance.some.hash' #NEWLINE# fake_marathon_service_config = marathon_tools . MarathonServiceConfig ( service = service , cluster = 'clustername' , instance = instance , config_dict = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } , branch_dict = { #NEWLINE# #INDENT# 'docker_image' : 'abcdef' , #NEWLINE# #UNINDENT# } ) #NEWLINE# fake_system_paasta_config = SystemPaastaConfig ( { #NEWLINE# #INDENT# 'volumes' : [ ] , #NEWLINE# 'docker_registry' : 'fake_docker_registry:443' , #NEWLINE# #UNINDENT# } , '/fake/dir/' ) #NEWLINE# fake_service_namespace_config = marathon_tools . ServiceNamespaceConfig ( { #NEWLINE# #INDENT# 'proxy_port' : 9001 , #NEWLINE# #UNINDENT# } ) #NEWLINE# with contextlib . nested ( mock . patch ( 'paasta_tools.marathon_tools.load_service_namespace_config' , return_value = expected ) , mock . patch ( 'paasta_tools.marathon_tools.format_job_id' , return_value = fake_job_id ) , mock . patch ( 'paasta_tools.marathon_tools.load_system_paasta_config' , return_value = fake_system_paasta_config ) , mock . patch ( 'paasta_tools.marathon_tools.get_mesos_slaves_grouped_by_attribute' , autospec = True , return_value = { #NEWLINE# #INDENT# 'fake_region' : { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } , #NEWLINE# #UNINDENT# } ) ) as ( mock_load_service_namespace_config , mock_format_job_id , mock_system_paasta_config , _ ) : #NEWLINE# #INDENT# actual = fake_marathon_service_config . format_marathon_app_dict ( ) #NEWLINE# expected = { #NEWLINE# #INDENT# 'container' : { #NEWLINE# #INDENT# 'docker' : { #NEWLINE# #INDENT# 'portMappings' : [ { #NEWLINE# #INDENT# 'protocol' : 'tcp' , #NEWLINE# 'containerPort' : 8888 , #NEWLINE# 'hostPort' : 0 , #NEWLINE# #UNINDENT# } ] , #NEWLINE# 'image' : 'fake_docker_registry:443/abcdef' , #NEWLINE# 'network' : 'BRIDGE' , #NEWLINE# 'parameters' : [ { #NEWLINE# #INDENT# 'key' : 'memory-swap' , #NEWLINE# 'value' : '1024m' , #NEWLINE# #UNINDENT# } ] , #NEWLINE# #UNINDENT# } , #NEWLINE# 'type' : 'DOCKER' , #NEWLINE# 'volumes' : [ ] , #NEWLINE# #UNINDENT# } , #NEWLINE# 'instances' : 1 , #NEWLINE# 'mem' : 1024 , #NEWLINE# 'cmd' : None , #NEWLINE# 'args' : [ ] , #NEWLINE# 'backoff_factor' : 2 , #NEWLINE# 'backoff_seconds' : mock . ANY , #NEWLINE# 'cpus' : 0.25 , #NEWLINE# 'disk' : 1024.0 , #NEWLINE# 'uris' : [ 'file:///root/.dockercfg' ] , #NEWLINE# 'health_checks' : [ { #NEWLINE# #INDENT# 'portIndex' : 0 , #NEWLINE# 'protocol' : 'HTTP' , #NEWLINE# 'timeoutSeconds' : 10 , #NEWLINE# 'intervalSeconds' : 10 , #NEWLINE# 'gracePeriodSeconds' : 60 , #NEWLINE# 'maxConsecutiveFailures' : 30 , #NEWLINE# 'path' : '/status' , #NEWLINE# #UNINDENT# } ] , #NEWLINE# 'env' : mock . ANY , #NEWLINE# 'id' : fake_job_id , #NEWLINE# 'constraints' : [ [ 'region' , 'GROUP_BY' , '1' ] , [ 'pool' , 'LIKE' , 'default' ] ] , #NEWLINE# #UNINDENT# } #NEWLINE# assert ( actual == expected ) #NEWLINE# assert MarathonApp ( ** actual )