<s> import contextlib <EOL> from datetime import datetime <EOL> from datetime import timedelta <EOL> import mock <EOL> from kazoo . exceptions import NoNodeError <EOL> from pytest import raises <EOL> from paasta_tools import autoscaling_lib <EOL> from paasta_tools import marathon_tools <EOL> def test_get_zookeeper_instances ( ) : <EOL> fake_marathon_config = marathon_tools . MarathonServiceConfig ( <EOL> service = '<STR_LIT>' , <EOL> instance = '<STR_LIT>' , <EOL> cluster = '<STR_LIT>' , <EOL> config_dict = { <EOL> '<STR_LIT>' : <NUM_LIT:5> , <EOL> '<STR_LIT>' : <NUM_LIT:10> , <EOL> } , <EOL> branch_dict = { } , <EOL> ) <EOL> with contextlib . nested ( <EOL> mock . patch ( '<STR_LIT>' , autospec = True ) , <EOL> mock . patch ( '<STR_LIT>' , autospec = True ) , <EOL> ) as ( <EOL> mock_zk_client , <EOL> _ , <EOL> ) : <EOL> mock_zk_get = mock . Mock ( return_value = ( <NUM_LIT:7> , None ) ) <EOL> mock_zk_client . return_value = mock . Mock ( get = mock_zk_get ) <EOL> assert fake_marathon_config . get_instances ( ) == <NUM_LIT:7> <EOL> assert mock_zk_get . call_count == <NUM_LIT:1> <EOL> def test_zookeeper_pool ( ) : <EOL> with contextlib . nested ( <EOL> mock . patch ( '<STR_LIT>' , autospec = True ) , <EOL> mock . patch ( '<STR_LIT>' , autospec = True ) , <EOL> ) as ( <EOL> mock_zk_client , <EOL> _ , <EOL> ) : <EOL> zk_client = mock . Mock ( ) <EOL> mock_zk_client . return_value = zk_client <EOL> with autoscaling_lib . ZookeeperPool ( ) : <EOL> with autoscaling_lib . ZookeeperPool ( ) : <EOL> assert zk_client . start . call_count == <NUM_LIT:1> <EOL> assert zk_client . stop . call_count == <NUM_LIT:0> <EOL> assert zk_client . stop . call_count == <NUM_LIT:1> <EOL> def test_get_zookeeper_instances_defaults_to_config_no_zk_node ( ) : <EOL> fake_marathon_config = marathon_tools . MarathonServiceConfig ( <EOL> service = '<STR_LIT>' , <EOL> instance = '<STR_LIT>' , <EOL> cluster = '<STR_LIT>' , <EOL> config_dict = { <EOL> '<STR_LIT>' : <NUM_LIT:5> , <EOL> '<STR_LIT>' : <NUM_LIT:10> , <EOL> } , <EOL> branch_dict = { } , <EOL> ) <EOL> with contextlib . nested ( <EOL> mock . patch ( '<STR_LIT>' , autospec = True ) , <EOL> mock . patch ( '<STR_LIT>' , autospec = True ) , <EOL> ) as ( <EOL> mock_zk_client , <EOL> _ , <EOL> ) : <EOL> mock_zk_client . return_value = mock . Mock ( get = mock . Mock ( side_effect = NoNodeError ) ) <EOL> assert fake_marathon_config . get_instances ( ) == <NUM_LIT:5> <EOL> def test_get_zookeeper_instances_defaults_to_config_out_of_bounds ( ) : <EOL> fake_marathon_config = marathon_tools . MarathonServiceConfig ( <EOL> service = '<STR_LIT>' , <EOL> instance = '<STR_LIT>' , <EOL> cluster = '<STR_LIT>' , <EOL> config_dict = { <EOL> '<STR_LIT>' : <NUM_LIT:5> , <EOL> '<STR_LIT>' : <NUM_LIT:10> , <EOL> } , <EOL> branch_dict = { } , <EOL> ) <EOL> with contextlib . nested ( <EOL> mock . patch ( '<STR_LIT>' , autospec = True ) , <EOL> mock . patch ( '<STR_LIT>' , autospec = True ) , <EOL> ) as ( <EOL> mock_zk_client , <EOL> _ , <EOL> ) : <EOL> mock_zk_client . return_value = mock . Mock ( get = mock . Mock ( return_value = ( <NUM_LIT:15> , None ) ) ) <EOL> assert fake_marathon_config . get_instances ( ) == <NUM_LIT:10> <EOL> mock_zk_client . return_value = mock . Mock ( get = mock . Mock ( return_value = ( <NUM_LIT:0> , None ) ) ) <EOL> assert fake_marathon_config . get_instances ( ) == <NUM_LIT:5> <EOL> def test_update_instances_for_marathon_service ( ) : <EOL> with contextlib . nested ( <EOL> mock . patch ( '<STR_LIT>' , autospec = True ) , <EOL> mock . patch ( '<STR_LIT>' , autospec = True ) , <EOL> mock . patch ( '<STR_LIT>' , autospec = True ) , <EOL> ) as ( <EOL> mock_load_marathon_service_config , <EOL> mock_zk_client , <EOL> _ , <EOL> ) : <EOL> zk_client = mock . Mock ( get = mock . Mock ( side_effect = NoNodeError ) ) <EOL> mock_zk_client . return_value = zk_client <EOL> mock_load_marathon_service_config . return_value = marathon_tools . MarathonServiceConfig ( <EOL> service = '<STR_LIT>' , <EOL> instance = '<STR_LIT>' , <EOL> cluster = '<STR_LIT>' , <EOL> config_dict = { <EOL> '<STR_LIT>' : <NUM_LIT:5> , <EOL> '<STR_LIT>' : <NUM_LIT:10> , <EOL> } , <EOL> branch_dict = { } , <EOL> ) <EOL> autoscaling_lib . set_instances_for_marathon_service ( '<STR_LIT>' , '<STR_LIT>' , instance_count = <NUM_LIT:8> ) <EOL> zk_client . set . assert_called_once_with ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> def test_compose_autoscaling_zookeeper_root ( ) : <EOL> assert autoscaling_lib . compose_autoscaling_zookeeper_root ( <EOL> '<STR_LIT>' , '<STR_LIT>' ) == '<STR_LIT>' <EOL> def test_get_service_metrics_provider ( ) : <EOL> assert autoscaling_lib . get_service_metrics_provider ( <EOL> '<STR_LIT>' ) == autoscaling_lib . mesos_cpu_metrics_provider <EOL> def test_get_decision_policy ( ) : <EOL> assert autoscaling_lib . get_decision_policy ( '<STR_LIT>' ) == autoscaling_lib . pid_decision_policy <EOL> def test_pid_decision_policy ( ) : <EOL> current_time = datetime . now ( ) <EOL> zookeeper_get_payload = { <EOL> '<STR_LIT>' : <NUM_LIT:0> , <EOL> '<STR_LIT>' : <NUM_LIT:0> , <EOL> '<STR_LIT>' : ( current_time - timedelta ( seconds = <NUM_LIT> ) ) . strftime ( '<STR_LIT:%s>' ) , <EOL> } <EOL> with contextlib . nested ( <EOL> mock . patch ( '<STR_LIT>' , autospec = True , <EOL> return_value = mock . Mock ( get = mock . Mock ( <EOL> side_effect = lambda x : ( zookeeper_get_payload [ x . split ( '<STR_LIT:/>' ) [ - <NUM_LIT:1> ] ] , None ) ) ) ) , <EOL> mock . patch ( '<STR_LIT>' , autospec = True ) , <EOL> mock . patch ( '<STR_LIT>' , autospec = True , <EOL> return_value = mock . Mock ( get_zk_hosts = mock . Mock ( ) ) ) , <EOL> ) as ( <EOL> mock_zk_client , <EOL> mock_datetime , <EOL> _ , <EOL> ) : <EOL> mock_datetime . now . return_value = current_time <EOL> assert autoscaling_lib . pid_decision_policy ( '<STR_LIT>' , <NUM_LIT:10> , <NUM_LIT:1> , <NUM_LIT:100> , <NUM_LIT:0.0> ) == <NUM_LIT:0> <EOL> assert autoscaling_lib . pid_decision_policy ( '<STR_LIT>' , <NUM_LIT:10> , <NUM_LIT:1> , <NUM_LIT:100> , <NUM_LIT> ) == <NUM_LIT:1> <EOL> assert autoscaling_lib . pid_decision_policy ( '<STR_LIT>' , <NUM_LIT:10> , <NUM_LIT:1> , <NUM_LIT:100> , - <NUM_LIT> ) == - <NUM_LIT:1> <EOL> mock_zk_client . return_value . set . assert_has_calls ( [ <EOL> mock . call ( '<STR_LIT>' , '<STR_LIT>' ) , <EOL> mock . call ( '<STR_LIT>' , '<STR_LIT>' ) , <EOL> mock . call ( '<STR_LIT>' , <EOL> '<STR_LIT:%s>' % current_time . strftime ( '<STR_LIT:%s>' ) ) , <EOL> ] , any_order = True ) <EOL> def test_threshold_decision_policy ( ) : <EOL> decision_policy_args = { <EOL> '<STR_LIT>' : <NUM_LIT:0.1> , <EOL> '<STR_LIT>' : <NUM_LIT:10> , <EOL> } <EOL> with contextlib . nested ( <EOL> mock . patch ( '<STR_LIT>' , autospec = True ) , <EOL> mock . patch ( '<STR_LIT>' , autospec = True , <EOL> return_value = mock . Mock ( get_zk_hosts = mock . Mock ( ) ) ) , <EOL> ) as ( <EOL> mock_datetime , <EOL> _ , <EOL> ) : <EOL> assert autoscaling_lib . threshold_decision_policy ( error = <NUM_LIT:0> , ** decision_policy_args ) == <NUM_LIT:0> <EOL> assert autoscaling_lib . threshold_decision_policy ( error = <NUM_LIT:0.5> , ** decision_policy_args ) == <NUM_LIT:1> <EOL> assert autoscaling_lib . threshold_decision_policy ( error = - <NUM_LIT:0.5> , ** decision_policy_args ) == - <NUM_LIT:1> <EOL> def test_mesos_cpu_metrics_provider ( ) : <EOL> fake_marathon_service_config = marathon_tools . MarathonServiceConfig ( <EOL> service = '<STR_LIT>' , <EOL> instance = '<STR_LIT>' , <EOL> cluster = '<STR_LIT>' , <EOL> config_dict = { } , <EOL> branch_dict = { } , <EOL> ) <EOL> fake_mesos_task = mock . MagicMock ( <EOL> stats = { <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> } , <EOL> ) <EOL> fake_mesos_task . __getitem__ . return_value = '<STR_LIT>' <EOL> fake_marathon_tasks = [ mock . Mock ( id = '<STR_LIT>' ) ] <EOL> with contextlib . nested ( <EOL> mock . patch ( '<STR_LIT>' , autospec = True , <EOL> return_value = mock . Mock ( get = mock . Mock ( <EOL> side_effect = NoNodeError ) ) ) , <EOL> mock . patch ( '<STR_LIT>' , autospec = True , <EOL> return_value = mock . Mock ( get_zk_hosts = mock . Mock ( ) ) ) , <EOL> ) as ( <EOL> mock_zk_client , <EOL> _ , <EOL> ) : <EOL> with raises ( autoscaling_lib . MetricsProviderNoDataError ) : <EOL> autoscaling_lib . mesos_cpu_metrics_provider ( <EOL> fake_marathon_service_config , fake_marathon_tasks , ( fake_mesos_task , ) ) <EOL> mock_zk_client . return_value . set . assert_has_calls ( [ <EOL> mock . call ( '<STR_LIT>' , '<STR_LIT>' ) , <EOL> ] , any_order = True ) <EOL> def test_mesos_cpu_metrics_provider_no_previous_cpu_data ( ) : <EOL> fake_marathon_service_config = marathon_tools . MarathonServiceConfig ( <EOL> service = '<STR_LIT>' , <EOL> instance = '<STR_LIT>' , <EOL> cluster = '<STR_LIT>' , <EOL> config_dict = { } , <EOL> branch_dict = { } , <EOL> ) <EOL> fake_mesos_task = mock . MagicMock ( <EOL> stats = { <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> '<STR_LIT>' : <NUM_LIT> , <EOL> } , <EOL> ) <EOL> fake_mesos_task . __getitem__ . return_value = '<STR_LIT>' <EOL> fake_marathon_tasks = [ mock . Mock ( id = '<STR_LIT>' ) ] <EOL> current_time = datetime . now ( ) <EOL> zookeeper_get_payload = { <EOL> '<STR_LIT>' : ( current_time - timedelta ( seconds = <NUM_LIT> ) ) . strftime ( '<STR_LIT:%s>' ) , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> } <EOL> with contextlib . nested ( <EOL> mock . patch ( '<STR_LIT>' , autospec = True , <EOL> return_value = mock . Mock ( get = mock . Mock ( <EOL> side_effect = lambda x : ( zookeeper_get_payload [ x . split ( '<STR_LIT:/>' ) [ - <NUM_LIT:1> ] ] , None ) ) ) ) , <EOL> mock . patch ( '<STR_LIT>' , autospec = True ) , <EOL> mock . patch ( '<STR_LIT>' , autospec = True , <EOL> return_value = mock . Mock ( get_zk_hosts = mock . Mock ( ) ) ) , <EOL> ) as ( <EOL> mock_zk_client , <EOL> mock_datetime , <EOL> _ , <EOL> ) : <EOL> mock_datetime . now . return_value = current_time <EOL> assert autoscaling_lib . mesos_cpu_metrics_provider ( <EOL> fake_marathon_service_config , fake_marathon_tasks , ( fake_mesos_task , ) ) == <NUM_LIT> <EOL> mock_zk_client . return_value . set . assert_has_calls ( [ <EOL> mock . call ( '<STR_LIT>' , current_time . strftime ( '<STR_LIT:%s>' ) ) , <EOL> mock . call ( '<STR_LIT>' , '<STR_LIT>' ) , <EOL> ] , any_order = True ) <EOL> def test_http_metrics_provider ( ) : <EOL> fake_marathon_service_config = marathon_tools . MarathonServiceConfig ( <EOL> service = '<STR_LIT>' , <EOL> instance = '<STR_LIT>' , <EOL> cluster = '<STR_LIT>' , <EOL> config_dict = { } , <EOL> branch_dict = { } , <EOL> ) <EOL> fake_marathon_tasks = [ mock . Mock ( id = '<STR_LIT>' , host = '<STR_LIT>' , ports = [ <NUM_LIT> ] ) ] <EOL> mock_request_result = mock . Mock ( json = mock . Mock ( return_value = { '<STR_LIT>' : '<STR_LIT>' } ) ) <EOL> with mock . patch ( '<STR_LIT>' , autospec = True , return_value = mock_request_result ) : <EOL> assert autoscaling_lib . http_metrics_provider ( <EOL> fake_marathon_service_config , fake_marathon_tasks , mock . Mock ( ) ) == <NUM_LIT:0.5> <EOL> def test_http_metrics_provider_no_data ( ) : <EOL> fake_marathon_service_config = marathon_tools . MarathonServiceConfig ( <EOL> service = '<STR_LIT>' , <EOL> instance = '<STR_LIT>' , <EOL> cluster = '<STR_LIT>' , <EOL> config_dict = { } , <EOL> branch_dict = { } , <EOL> ) <EOL> fake_marathon_tasks = [ mock . Mock ( id = '<STR_LIT>' , host = '<STR_LIT>' , ports = [ <NUM_LIT> ] ) ] <EOL> mock_request_result = mock . Mock ( json = mock . Mock ( return_value = '<STR_LIT>' ) ) <EOL> with mock . patch ( '<STR_LIT>' , autospec = True , return_value = mock_request_result ) : <EOL> with raises ( autoscaling_lib . MetricsProviderNoDataError ) : <EOL> autoscaling_lib . http_metrics_provider ( fake_marathon_service_config , fake_marathon_tasks , mock . Mock ( ) ) == <NUM_LIT:0.5> <EOL> def test_mesos_cpu_metrics_provider_no_data_mesos ( ) : <EOL> fake_marathon_service_config = marathon_tools . MarathonServiceConfig ( <EOL> service = '<STR_LIT>' , <EOL> instance = '<STR_LIT>' , <EOL> cluster = '<STR_LIT>' , <EOL> config_dict = { } , <EOL> branch_dict = { } , <EOL> ) <EOL> fake_marathon_tasks = [ mock . Mock ( id = '<STR_LIT>' ) ] <EOL> zookeeper_get_payload = { <EOL> '<STR_LIT>' : '<STR_LIT:0>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> } <EOL> with contextlib . nested ( <EOL> mock . patch ( '<STR_LIT>' , autospec = True , <EOL> return_value = mock . Mock ( get = mock . Mock ( <EOL> side_effect = lambda x : ( zookeeper_get_payload [ x . split ( '<STR_LIT:/>' ) [ - <NUM_LIT:1> ] ] , None ) ) ) ) , <EOL> mock . patch ( '<STR_LIT>' , autospec = True , <EOL> return_value = mock . Mock ( get_zk_hosts = mock . Mock ( ) ) ) , <EOL> ) as ( <EOL> _ , <EOL> _ , <EOL> ) : <EOL> with raises ( autoscaling_lib . MetricsProviderNoDataError ) : <EOL> autoscaling_lib . mesos_cpu_metrics_provider ( fake_marathon_service_config , fake_marathon_tasks , [ ] ) <EOL> def test_autoscale_marathon_instance ( ) : <EOL> fake_marathon_service_config = marathon_tools . MarathonServiceConfig ( <EOL> service = '<STR_LIT>' , <EOL> instance = '<STR_LIT>' , <EOL> cluster = '<STR_LIT>' , <EOL> config_dict = { '<STR_LIT>' : <NUM_LIT:1> , '<STR_LIT>' : <NUM_LIT:10> } , <EOL> branch_dict = { } , <EOL> ) <EOL> with contextlib . nested ( <EOL> mock . patch ( '<STR_LIT>' , autospec = True ) , <EOL> mock . patch ( '<STR_LIT>' , autospec = True ) , <EOL> mock . patch ( '<STR_LIT>' , autospec = True , <EOL> return_value = mock . Mock ( return_value = <NUM_LIT:1> ) ) , <EOL> mock . patch . object ( marathon_tools . MarathonServiceConfig , '<STR_LIT>' , autospec = True , return_value = <NUM_LIT:1> ) , <EOL> mock . patch ( '<STR_LIT>' , autospec = True ) , <EOL> ) as ( <EOL> mock_set_instances_for_marathon_service , <EOL> _ , <EOL> _ , <EOL> _ , <EOL> _ , <EOL> ) : <EOL> autoscaling_lib . autoscale_marathon_instance ( fake_marathon_service_config , [ mock . Mock ( ) ] , [ mock . Mock ( ) ] ) <EOL> mock_set_instances_for_marathon_service . assert_called_once_with ( <EOL> service = '<STR_LIT>' , instance = '<STR_LIT>' , instance_count = <NUM_LIT:2> ) <EOL> def test_autoscale_marathon_instance_aborts_when_task_deploying ( ) : <EOL> fake_marathon_service_config = marathon_tools . MarathonServiceConfig ( <EOL> service = '<STR_LIT>' , <EOL> instance = '<STR_LIT>' , <EOL> cluster = '<STR_LIT>' , <EOL> config_dict = { '<STR_LIT>' : <NUM_LIT:1> , '<STR_LIT>' : <NUM_LIT:10> } , <EOL> branch_dict = { } , <EOL> ) <EOL> with contextlib . nested ( <EOL> mock . patch ( '<STR_LIT>' , autospec = True ) , <EOL> mock . patch ( '<STR_LIT>' , autospec = True ) , <EOL> mock . patch ( '<STR_LIT>' , autospec = True , <EOL> return_value = mock . Mock ( return_value = <NUM_LIT:1> ) ) , <EOL> mock . patch . object ( marathon_tools . MarathonServiceConfig , '<STR_LIT>' , autospec = True , return_value = <NUM_LIT> ) , <EOL> mock . patch ( '<STR_LIT>' , autospec = True ) , <EOL> ) as ( <EOL> mock_set_instances_for_marathon_service , <EOL> _ , <EOL> _ , <EOL> _ , <EOL> _ , <EOL> ) : <EOL> autoscaling_lib . autoscale_marathon_instance ( fake_marathon_service_config , [ mock . Mock ( ) ] , [ mock . Mock ( ) ] ) <EOL> assert not mock_set_instances_for_marathon_service . called <EOL> def test_autoscale_services ( ) : <EOL> fake_marathon_service_config = marathon_tools . MarathonServiceConfig ( <EOL> service = '<STR_LIT>' , <EOL> instance = '<STR_LIT>' , <EOL> cluster = '<STR_LIT>' , <EOL> config_dict = { '<STR_LIT>' : <NUM_LIT:1> , '<STR_LIT>' : <NUM_LIT:10> , '<STR_LIT>' : '<STR_LIT:start>' } , <EOL> branch_dict = { } , <EOL> ) <EOL> mock_mesos_tasks = [ { '<STR_LIT:id>' : '<STR_LIT>' } ] <EOL> mock_marathon_tasks = [ mock . Mock ( id = '<STR_LIT>' ) ] <EOL> with contextlib . nested ( <EOL> mock . patch ( '<STR_LIT>' , autospec = True ) , <EOL> mock . patch ( '<STR_LIT>' , autospec = True , <EOL> return_value = mock . Mock ( list_tasks = mock . Mock ( return_value = mock_marathon_tasks ) ) ) , <EOL> mock . patch ( '<STR_LIT>' , autospec = True , <EOL> return_value = mock_mesos_tasks ) , <EOL> mock . patch ( '<STR_LIT>' , autospec = True , <EOL> return_value = mock . Mock ( get_cluster = mock . Mock ( ) ) ) , <EOL> mock . patch ( '<STR_LIT>' , autospec = True , <EOL> return_value = mock . Mock ( get_zk_hosts = mock . Mock ( ) ) ) , <EOL> mock . patch ( '<STR_LIT>' , autospec = True , <EOL> return_value = [ ( '<STR_LIT>' , '<STR_LIT>' ) ] ) , <EOL> mock . patch ( '<STR_LIT>' , autospec = True , <EOL> return_value = fake_marathon_service_config ) , <EOL> mock . patch ( '<STR_LIT>' , autospec = True ) , <EOL> mock . patch ( '<STR_LIT>' , autospec = True ) , <EOL> mock . patch ( '<STR_LIT>' , autospec = True ) , <EOL> ) as ( <EOL> mock_autoscale_marathon_instance , <EOL> _ , <EOL> _ , <EOL> _ , <EOL> _ , <EOL> _ , <EOL> _ , <EOL> _ , <EOL> _ , <EOL> _ , <EOL> ) : <EOL> autoscaling_lib . autoscale_services ( ) <EOL> mock_autoscale_marathon_instance . assert_called_once_with ( <EOL> fake_marathon_service_config , mock_marathon_tasks , mock_mesos_tasks ) <EOL> def test_autoscale_services_bespoke_doesnt_autoscale ( ) : <EOL> fake_marathon_service_config = marathon_tools . MarathonServiceConfig ( <EOL> service = '<STR_LIT>' , <EOL> instance = '<STR_LIT>' , <EOL> cluster = '<STR_LIT>' , <EOL> config_dict = { '<STR_LIT>' : <NUM_LIT:1> , '<STR_LIT>' : <NUM_LIT:10> , '<STR_LIT>' : '<STR_LIT:start>' , <EOL> '<STR_LIT>' : { '<STR_LIT>' : '<STR_LIT>' } } , <EOL> branch_dict = { } , <EOL> ) <EOL> mock_mesos_tasks = [ { '<STR_LIT:id>' : '<STR_LIT>' } ] <EOL> mock_marathon_tasks = [ mock . Mock ( id = '<STR_LIT>' ) ] <EOL> with contextlib . nested ( <EOL> mock . patch ( '<STR_LIT>' , autospec = True ) , <EOL> mock . patch ( '<STR_LIT>' , autospec = True , <EOL> return_value = mock . Mock ( list_tasks = mock . Mock ( return_value = mock_marathon_tasks ) ) ) , <EOL> mock . patch ( '<STR_LIT>' , autospec = True , <EOL> return_value = mock_mesos_tasks ) , <EOL> mock . patch ( '<STR_LIT>' , autospec = True , <EOL> return_value = mock . Mock ( get_cluster = mock . Mock ( ) ) ) , <EOL> mock . patch ( '<STR_LIT>' , autospec = True , <EOL> return_value = mock . Mock ( get_zk_hosts = mock . Mock ( ) ) ) , <EOL> mock . patch ( '<STR_LIT>' , autospec = True , <EOL> return_value = [ ( '<STR_LIT>' , '<STR_LIT>' ) ] ) , <EOL> mock . patch ( '<STR_LIT>' , autospec = True , <EOL> return_value = fake_marathon_service_config ) , <EOL> mock . patch ( '<STR_LIT>' , autospec = True ) , <EOL> mock . patch ( '<STR_LIT>' , autospec = True ) , <EOL> mock . patch ( '<STR_LIT>' , autospec = True ) , <EOL> ) as ( <EOL> mock_autoscale_marathon_instance , <EOL> _ , <EOL> _ , <EOL> _ , <EOL> _ , <EOL> _ , <EOL> _ , <EOL> _ , <EOL> _ , <EOL> _ , <EOL> ) : <EOL> autoscaling_lib . autoscale_services ( ) <EOL> assert not mock_autoscale_marathon_instance . called </s>
