<s> import contextlib <EOL> import os <EOL> from StringIO import StringIO <EOL> from mock import call <EOL> from mock import MagicMock <EOL> from mock import patch <EOL> from paasta_tools . cli . cmds . check import deploy_check <EOL> from paasta_tools . cli . cmds . check import deploy_has_performance_check <EOL> from paasta_tools . cli . cmds . check import deploy_has_security_check <EOL> from paasta_tools . cli . cmds . check import deployments_check <EOL> from paasta_tools . cli . cmds . check import docker_check <EOL> from paasta_tools . cli . cmds . check import get_marathon_steps <EOL> from paasta_tools . cli . cmds . check import makefile_check <EOL> from paasta_tools . cli . cmds . check import makefile_has_a_tab <EOL> from paasta_tools . cli . cmds . check import makefile_has_docker_tag <EOL> from paasta_tools . cli . cmds . check import makefile_responds_to <EOL> from paasta_tools . cli . cmds . check import NoSuchService <EOL> from paasta_tools . cli . cmds . check import paasta_check <EOL> from paasta_tools . cli . cmds . check import pipeline_check <EOL> from paasta_tools . cli . cmds . check import sensu_check <EOL> from paasta_tools . cli . cmds . check import service_dir_check <EOL> from paasta_tools . cli . cmds . check import smartstack_check <EOL> from paasta_tools . cli . cmds . check import yaml_check <EOL> from paasta_tools . cli . utils import PaastaCheckMessages <EOL> from paasta_tools . marathon_tools import MarathonServiceConfig <EOL> @ patch ( '<STR_LIT>' ) <EOL> @ patch ( '<STR_LIT>' ) <EOL> @ patch ( '<STR_LIT>' ) <EOL> @ patch ( '<STR_LIT>' ) <EOL> @ patch ( '<STR_LIT>' ) <EOL> @ patch ( '<STR_LIT>' ) <EOL> @ patch ( '<STR_LIT>' ) <EOL> @ patch ( '<STR_LIT>' ) <EOL> @ patch ( '<STR_LIT>' ) <EOL> @ patch ( '<STR_LIT>' ) <EOL> @ patch ( '<STR_LIT>' ) <EOL> @ patch ( '<STR_LIT>' ) <EOL> @ patch ( '<STR_LIT>' ) <EOL> @ patch ( '<STR_LIT>' ) <EOL> @ patch ( '<STR_LIT>' ) <EOL> def test_check_paasta_check_calls_everything ( <EOL> mock_paasta_validate_soa_configs , <EOL> mock_smartstart_check , <EOL> mock_sensu_check , <EOL> mock_deployments_check , <EOL> mock_yaml_check , <EOL> mock_makefile_check , <EOL> mock_docker_check , <EOL> mock_deploy_check , <EOL> mock_deploy_security_check , <EOL> mock_deploy_performance_check , <EOL> mock_figure_out_service_name , <EOL> mock_validate_service_name , <EOL> mock_service_dir_check , <EOL> mock_pipeline_check , <EOL> mock_git_repo_check <EOL> ) : <EOL> mock_figure_out_service_name . return_value = '<STR_LIT>' <EOL> mock_validate_service_name . return_value = None <EOL> args = MagicMock ( ) <EOL> args . yelpsoa_config_root = '<STR_LIT>' <EOL> paasta_check ( args ) <EOL> assert mock_git_repo_check . called <EOL> assert mock_pipeline_check . called <EOL> assert mock_service_dir_check . called <EOL> assert mock_deploy_check . called <EOL> assert mock_deploy_security_check . called <EOL> assert mock_deploy_performance_check . called <EOL> assert mock_docker_check . called <EOL> assert mock_makefile_check . called <EOL> assert mock_yaml_check . called <EOL> assert mock_sensu_check . called <EOL> assert mock_smartstart_check . called <EOL> assert mock_paasta_validate_soa_configs . called <EOL> service_path = os . path . join ( args . yelpsoa_config_root , <EOL> mock_figure_out_service_name . return_value ) <EOL> mock_deploy_check . assert_called_once_with ( service_path ) <EOL> @ patch ( '<STR_LIT>' , autospec = True ) <EOL> @ patch ( '<STR_LIT>' , new_callable = StringIO ) <EOL> def test_check_service_dir_check_pass ( mock_stdout , mock_validate_service_name ) : <EOL> mock_validate_service_name . return_value = None <EOL> service = '<STR_LIT>' <EOL> soa_dir = '<STR_LIT>' <EOL> expected_output = "<STR_LIT>" % PaastaCheckMessages . service_dir_found ( service , soa_dir ) <EOL> service_dir_check ( service , soa_dir ) <EOL> output = mock_stdout . getvalue ( ) <EOL> assert output == expected_output <EOL> @ patch ( '<STR_LIT>' , autospec = True ) <EOL> @ patch ( '<STR_LIT>' , new_callable = StringIO ) <EOL> def test_check_service_dir_check_fail ( mock_stdout , mock_validate_service_name ) : <EOL> service = '<STR_LIT>' <EOL> soa_dir = '<STR_LIT>' <EOL> mock_validate_service_name . side_effect = NoSuchService ( service ) <EOL> expected_output = "<STR_LIT>" % PaastaCheckMessages . service_dir_missing ( service , soa_dir ) <EOL> service_dir_check ( service , soa_dir ) <EOL> output = mock_stdout . getvalue ( ) <EOL> assert output == expected_output <EOL> @ patch ( '<STR_LIT>' ) <EOL> @ patch ( '<STR_LIT>' , new_callable = StringIO ) <EOL> def test_check_deploy_check_pass ( mock_stdout , mock_is_file_in_dir ) : <EOL> mock_is_file_in_dir . return_value = True <EOL> deploy_check ( '<STR_LIT>' ) <EOL> expected_output = "<STR_LIT>" % PaastaCheckMessages . DEPLOY_YAML_FOUND <EOL> output = mock_stdout . getvalue ( ) <EOL> assert output == expected_output <EOL> @ patch ( '<STR_LIT>' ) <EOL> @ patch ( '<STR_LIT>' , new_callable = StringIO ) <EOL> def test_check_deploy_check_fail ( mock_stdout , mock_is_file_in_dir ) : <EOL> mock_is_file_in_dir . return_value = False <EOL> deploy_check ( '<STR_LIT>' ) <EOL> expected_output = "<STR_LIT>" % PaastaCheckMessages . DEPLOY_YAML_MISSING <EOL> output = mock_stdout . getvalue ( ) <EOL> assert output == expected_output <EOL> @ patch ( '<STR_LIT>' ) <EOL> @ patch ( '<STR_LIT>' , new_callable = StringIO ) <EOL> def test_check_docker_exists_and_is_valid ( <EOL> mock_stdout , <EOL> mock_is_file_in_dir , <EOL> ) : <EOL> mock_is_file_in_dir . return_value = "<STR_LIT>" <EOL> docker_check ( ) <EOL> output = mock_stdout . getvalue ( ) <EOL> assert PaastaCheckMessages . DOCKERFILE_FOUND in output <EOL> @ patch ( '<STR_LIT>' ) <EOL> @ patch ( '<STR_LIT>' , new_callable = StringIO ) <EOL> def test_check_docker_check_file_not_found ( <EOL> mock_stdout , <EOL> mock_is_file_in_dir <EOL> ) : <EOL> mock_is_file_in_dir . return_value = False <EOL> docker_check ( ) <EOL> output = mock_stdout . getvalue ( ) <EOL> assert PaastaCheckMessages . DOCKERFILE_MISSING in output <EOL> @ patch ( '<STR_LIT>' ) <EOL> @ patch ( '<STR_LIT>' , new_callable = StringIO ) <EOL> def test_check_yaml_check_pass ( mock_stdout , mock_is_file_in_dir ) : <EOL> mock_is_file_in_dir . return_value = "<STR_LIT>" <EOL> expected_output = "<STR_LIT>" % ( PaastaCheckMessages . MARATHON_YAML_FOUND , <EOL> PaastaCheckMessages . CHRONOS_YAML_FOUND ) <EOL> yaml_check ( '<STR_LIT:path>' ) <EOL> output = mock_stdout . getvalue ( ) <EOL> assert output == expected_output <EOL> @ patch ( '<STR_LIT>' ) <EOL> @ patch ( '<STR_LIT>' , new_callable = StringIO ) <EOL> def test_check_yaml_check_fail ( mock_stdout , mock_is_file_in_dir ) : <EOL> mock_is_file_in_dir . return_value = False <EOL> expected_output = "<STR_LIT>" % PaastaCheckMessages . YAML_MISSING <EOL> yaml_check ( '<STR_LIT:path>' ) <EOL> output = mock_stdout . getvalue ( ) <EOL> assert output == expected_output <EOL> @ patch ( '<STR_LIT>' ) <EOL> @ patch ( '<STR_LIT>' ) <EOL> @ patch ( '<STR_LIT>' , new_callable = StringIO ) <EOL> def test_check_sensu_check_pass ( mock_stdout , mock_get_team , <EOL> mock_is_file_in_dir ) : <EOL> mock_is_file_in_dir . return_value = "<STR_LIT>" <EOL> team = '<STR_LIT>' <EOL> mock_get_team . return_value = team <EOL> expected_output = "<STR_LIT>" % ( PaastaCheckMessages . SENSU_MONITORING_FOUND , <EOL> PaastaCheckMessages . sensu_team_found ( team ) ) <EOL> sensu_check ( service = '<STR_LIT>' , service_path = '<STR_LIT:path>' , soa_dir = '<STR_LIT:path>' ) <EOL> output = mock_stdout . getvalue ( ) <EOL> assert output == expected_output <EOL> mock_get_team . assert_called_once_with ( service = '<STR_LIT>' , overrides = { } , <EOL> soa_dir = '<STR_LIT:path>' ) <EOL> @ patch ( '<STR_LIT>' ) <EOL> @ patch ( '<STR_LIT>' ) <EOL> @ patch ( '<STR_LIT>' , new_callable = StringIO ) <EOL> def test_check_sensu_team_missing ( mock_stdout , mock_get_team , <EOL> mock_is_file_in_dir ) : <EOL> mock_is_file_in_dir . return_value = "<STR_LIT>" <EOL> mock_get_team . return_value = None <EOL> expected_output = "<STR_LIT>" % ( PaastaCheckMessages . SENSU_MONITORING_FOUND , <EOL> PaastaCheckMessages . SENSU_TEAM_MISSING ) <EOL> sensu_check ( service = '<STR_LIT>' , service_path = '<STR_LIT:path>' , soa_dir = '<STR_LIT:path>' ) <EOL> output = mock_stdout . getvalue ( ) <EOL> assert output == expected_output <EOL> @ patch ( '<STR_LIT>' ) <EOL> @ patch ( '<STR_LIT>' , new_callable = StringIO ) <EOL> def test_check_sensu_check_fail ( mock_stdout , mock_is_file_in_dir ) : <EOL> mock_is_file_in_dir . return_value = False <EOL> expected_output = "<STR_LIT>" % PaastaCheckMessages . SENSU_MONITORING_MISSING <EOL> sensu_check ( service = '<STR_LIT>' , service_path = '<STR_LIT:path>' , soa_dir = '<STR_LIT:path>' ) <EOL> output = mock_stdout . getvalue ( ) <EOL> assert output == expected_output <EOL> @ patch ( '<STR_LIT>' <EOL> '<STR_LIT>' ) <EOL> @ patch ( '<STR_LIT>' ) <EOL> @ patch ( '<STR_LIT>' , new_callable = StringIO ) <EOL> def test_check_smartstack_check_pass ( mock_stdout , mock_is_file_in_dir , <EOL> mock_read_service_info ) : <EOL> mock_is_file_in_dir . return_value = True <EOL> port = <NUM_LIT> <EOL> instance = '<STR_LIT>' <EOL> smartstack_dict = { <EOL> '<STR_LIT>' : { <EOL> instance : { <EOL> '<STR_LIT>' : port <EOL> } <EOL> } <EOL> } <EOL> mock_read_service_info . return_value = smartstack_dict <EOL> expected_output = "<STR_LIT>" % ( PaastaCheckMessages . SMARTSTACK_YAML_FOUND , <EOL> PaastaCheckMessages . smartstack_port_found ( <EOL> instance , port ) ) <EOL> smartstack_check ( service = '<STR_LIT>' , service_path = '<STR_LIT:path>' , soa_dir = '<STR_LIT:path>' ) <EOL> output = mock_stdout . getvalue ( ) <EOL> assert output == expected_output <EOL> @ patch ( '<STR_LIT>' <EOL> '<STR_LIT>' ) <EOL> @ patch ( '<STR_LIT>' ) <EOL> @ patch ( '<STR_LIT>' , new_callable = StringIO ) <EOL> def test_check_smartstack_check_missing_port ( <EOL> mock_stdout , mock_is_file_in_dir , mock_read_service_info ) : <EOL> mock_is_file_in_dir . return_value = True <EOL> instance = '<STR_LIT>' <EOL> smartstack_dict = { <EOL> instance : { <EOL> '<STR_LIT:foo>' : <NUM_LIT:0> <EOL> } <EOL> } <EOL> mock_read_service_info . return_value = smartstack_dict <EOL> expected_output = "<STR_LIT>" % ( PaastaCheckMessages . SMARTSTACK_YAML_FOUND , <EOL> PaastaCheckMessages . SMARTSTACK_PORT_MISSING ) <EOL> smartstack_check ( service = '<STR_LIT>' , service_path = '<STR_LIT:path>' , soa_dir = '<STR_LIT:path>' ) <EOL> output = mock_stdout . getvalue ( ) <EOL> assert output == expected_output <EOL> @ patch ( '<STR_LIT>' <EOL> '<STR_LIT>' ) <EOL> @ patch ( '<STR_LIT>' ) <EOL> @ patch ( '<STR_LIT>' , new_callable = StringIO ) <EOL> def test_check_smartstack_check_missing_instance ( <EOL> mock_stdout , mock_is_file_in_dir , mock_read_service_info ) : <EOL> mock_is_file_in_dir . return_value = True <EOL> smartstack_dict = { } <EOL> mock_read_service_info . return_value = smartstack_dict <EOL> expected_output = "<STR_LIT>" % ( PaastaCheckMessages . SMARTSTACK_YAML_FOUND , <EOL> PaastaCheckMessages . SMARTSTACK_PORT_MISSING ) <EOL> smartstack_check ( service = '<STR_LIT>' , service_path = '<STR_LIT:path>' , soa_dir = '<STR_LIT:path>' ) <EOL> output = mock_stdout . getvalue ( ) <EOL> assert output == expected_output <EOL> @ patch ( '<STR_LIT>' ) <EOL> @ patch ( '<STR_LIT>' , new_callable = StringIO ) <EOL> def test_check_smartstack_check_is_ok_when_no_smartstack ( mock_stdout , mock_is_file_in_dir ) : <EOL> mock_is_file_in_dir . return_value = False <EOL> expected_output = "<STR_LIT>" <EOL> smartstack_check ( service = '<STR_LIT>' , service_path = '<STR_LIT:path>' , soa_dir = '<STR_LIT:path>' ) <EOL> output = mock_stdout . getvalue ( ) <EOL> assert output == expected_output <EOL> @ patch ( '<STR_LIT>' ) <EOL> @ patch ( '<STR_LIT>' , new_callable = StringIO ) <EOL> def test_check_pipeline_check_pass ( mock_stdout , mock_urlopen ) : <EOL> mock_result = MagicMock ( ) <EOL> mock_result . getcode . return_value = <NUM_LIT:200> <EOL> mock_urlopen . return_value = mock_result <EOL> expected_output = "<STR_LIT>" % PaastaCheckMessages . PIPELINE_FOUND <EOL> pipeline_check ( "<STR_LIT>" ) <EOL> output = mock_stdout . getvalue ( ) <EOL> assert output == expected_output <EOL> @ patch ( '<STR_LIT>' ) <EOL> @ patch ( '<STR_LIT>' , new_callable = StringIO ) <EOL> def test_check_pipeline_check_fail_404 ( mock_stdout , mock_urlopen ) : <EOL> mock_result = MagicMock ( ) <EOL> mock_result . getcode . return_value = <NUM_LIT> <EOL> mock_urlopen . return_value = mock_result <EOL> expected_output = "<STR_LIT>" % PaastaCheckMessages . PIPELINE_MISSING <EOL> pipeline_check ( "<STR_LIT>" ) <EOL> output = mock_stdout . getvalue ( ) <EOL> assert output == expected_output <EOL> @ patch ( '<STR_LIT>' ) <EOL> @ patch ( '<STR_LIT>' ) <EOL> @ patch ( '<STR_LIT>' , new_callable = StringIO ) <EOL> def test_check_pipeline_check_fail_httperr ( mock_stdout , mock_urllib2 , mock_error ) : <EOL> mock_urllib2 . urlopen . side_effect = mock_error <EOL> expected_output = "<STR_LIT>" % PaastaCheckMessages . PIPELINE_MISSING <EOL> pipeline_check ( "<STR_LIT>" ) <EOL> output = mock_stdout . getvalue ( ) <EOL> assert output == expected_output <EOL> @ patch ( '<STR_LIT>' ) <EOL> def test_makefile_responds_to_good ( mock_run ) : <EOL> mock_run . return_value = ( <NUM_LIT:1> , '<STR_LIT>' ) <EOL> actual = makefile_responds_to ( '<STR_LIT>' ) <EOL> assert actual is True <EOL> @ patch ( '<STR_LIT>' ) <EOL> def test_makefile_responds_to_run ( mock_run ) : <EOL> mock_run . return_value = ( <NUM_LIT:2> , '<STR_LIT>' ) <EOL> actual = makefile_responds_to ( '<STR_LIT>' ) <EOL> assert actual is False <EOL> def test_makefile_has_a_tab_true ( ) : <EOL> fake_makefile_path = '<STR_LIT>' <EOL> fake_contents = '<STR_LIT>' <EOL> with contextlib . nested ( <EOL> patch ( <EOL> '<STR_LIT>' , <EOL> autospec = True , <EOL> return_value = fake_contents <EOL> ) , <EOL> ) as ( <EOL> mock_get_file_contents , <EOL> ) : <EOL> assert makefile_has_a_tab ( fake_makefile_path ) is True <EOL> def test_makefile_has_a_tab_false ( ) : <EOL> fake_makefile_path = '<STR_LIT>' <EOL> fake_contents = '<STR_LIT>' <EOL> with contextlib . nested ( <EOL> patch ( <EOL> '<STR_LIT>' , <EOL> autospec = True , <EOL> return_value = fake_contents <EOL> ) , <EOL> ) as ( <EOL> mock_get_file_contents , <EOL> ) : <EOL> assert makefile_has_a_tab ( fake_makefile_path ) is False <EOL> def test_makefile_has_docker_tag_true ( ) : <EOL> fake_makefile_path = '<STR_LIT>' <EOL> fake_contents = '<STR_LIT>' <EOL> with contextlib . nested ( <EOL> patch ( <EOL> '<STR_LIT>' , <EOL> autospec = True , <EOL> return_value = fake_contents <EOL> ) , <EOL> ) as ( <EOL> mock_get_file_contents , <EOL> ) : <EOL> assert makefile_has_docker_tag ( fake_makefile_path ) is True <EOL> def test_makefile_has_docker_tag_false ( ) : <EOL> fake_makefile_path = '<STR_LIT>' <EOL> fake_contents = '<STR_LIT>' <EOL> with contextlib . nested ( <EOL> patch ( <EOL> '<STR_LIT>' , <EOL> autospec = True , <EOL> return_value = fake_contents <EOL> ) , <EOL> ) as ( <EOL> mock_get_file_contents , <EOL> ) : <EOL> assert makefile_has_docker_tag ( fake_makefile_path ) is False <EOL> @ patch ( '<STR_LIT>' , new_callable = StringIO ) <EOL> @ patch ( '<STR_LIT>' ) <EOL> def test_deploy_has_security_check_false ( mock_pipeline_config , mock_stdout ) : <EOL> mock_pipeline_config . return_value = [ <EOL> { '<STR_LIT>' : '<STR_LIT>' , } , <EOL> { '<STR_LIT>' : '<STR_LIT>' , } , <EOL> { '<STR_LIT>' : '<STR_LIT>' , '<STR_LIT>' : True , } , <EOL> { '<STR_LIT>' : '<STR_LIT>' , } , <EOL> ] <EOL> actual = deploy_has_security_check ( service = '<STR_LIT>' , soa_dir = '<STR_LIT>' ) <EOL> assert actual is False <EOL> @ patch ( '<STR_LIT>' , new_callable = StringIO ) <EOL> @ patch ( '<STR_LIT>' ) <EOL> def test_deploy_has_security_check_true ( mock_pipeline_config , mock_stdout ) : <EOL> mock_pipeline_config . return_value = [ <EOL> { '<STR_LIT>' : '<STR_LIT>' , } , <EOL> { '<STR_LIT>' : '<STR_LIT>' , } , <EOL> { '<STR_LIT>' : '<STR_LIT>' , } , <EOL> { '<STR_LIT>' : '<STR_LIT>' , '<STR_LIT>' : True , } , <EOL> { '<STR_LIT>' : '<STR_LIT>' , } , <EOL> ] <EOL> actual = deploy_has_security_check ( service = '<STR_LIT>' , soa_dir = '<STR_LIT>' ) <EOL> assert actual is True <EOL> @ patch ( '<STR_LIT>' , new_callable = StringIO ) <EOL> @ patch ( '<STR_LIT>' ) <EOL> def test_deploy_has_performance_check_false ( mock_pipeline_config , mock_stdout ) : <EOL> mock_pipeline_config . return_value = [ <EOL> { '<STR_LIT>' : '<STR_LIT>' , } , <EOL> { '<STR_LIT>' : '<STR_LIT>' , } , <EOL> { '<STR_LIT>' : '<STR_LIT>' , '<STR_LIT>' : True , } , <EOL> { '<STR_LIT>' : '<STR_LIT>' , } , <EOL> ] <EOL> actual = deploy_has_performance_check ( service = '<STR_LIT>' , soa_dir = '<STR_LIT>' ) <EOL> assert actual is False <EOL> @ patch ( '<STR_LIT>' , new_callable = StringIO ) <EOL> @ patch ( '<STR_LIT>' ) <EOL> def test_deploy_has_performance_check_true ( mock_pipeline_config , mock_stdout ) : <EOL> mock_pipeline_config . return_value = [ <EOL> { '<STR_LIT>' : '<STR_LIT>' , } , <EOL> { '<STR_LIT>' : '<STR_LIT>' , } , <EOL> { '<STR_LIT>' : '<STR_LIT>' , } , <EOL> { '<STR_LIT>' : '<STR_LIT>' , '<STR_LIT>' : True , } , <EOL> { '<STR_LIT>' : '<STR_LIT>' , } , <EOL> ] <EOL> actual = deploy_has_performance_check ( service = '<STR_LIT>' , soa_dir = '<STR_LIT>' ) <EOL> assert actual is True <EOL> @ patch ( '<STR_LIT>' ) <EOL> @ patch ( '<STR_LIT>' ) <EOL> @ patch ( '<STR_LIT>' ) <EOL> def test_get_marathon_steps ( <EOL> mock_get_service_instance_list , <EOL> mock_list_clusters , <EOL> mock_load_marathon_service_config , <EOL> ) : <EOL> mock_list_clusters . return_value = [ '<STR_LIT>' ] <EOL> mock_get_service_instance_list . return_value = [ ( '<STR_LIT>' , '<STR_LIT>' ) , ( '<STR_LIT>' , '<STR_LIT>' ) ] <EOL> mock_load_marathon_service_config . side_effect = lambda service , instance , cluster , soa_dir , load_deployments : MarathonServiceConfig ( <EOL> service = service , <EOL> instance = instance , <EOL> cluster = cluster , <EOL> config_dict = { } , <EOL> branch_dict = { } , <EOL> ) <EOL> expected = [ '<STR_LIT>' , '<STR_LIT>' ] <EOL> actual = get_marathon_steps ( service = '<STR_LIT>' , soa_dir = '<STR_LIT>' ) <EOL> assert actual == expected <EOL> @ patch ( '<STR_LIT>' , new_callable = StringIO ) <EOL> @ patch ( '<STR_LIT>' ) <EOL> @ patch ( '<STR_LIT>' ) <EOL> def test_marathon_deployments_check_good ( <EOL> mock_get_marathon_steps , <EOL> mock_get_pipeline_config , <EOL> mock_stdout , <EOL> ) : <EOL> mock_get_pipeline_config . return_value = [ <EOL> { '<STR_LIT>' : '<STR_LIT>' , } , <EOL> { '<STR_LIT>' : '<STR_LIT>' , } , <EOL> { '<STR_LIT>' : '<STR_LIT>' , } , <EOL> { '<STR_LIT>' : '<STR_LIT>' , '<STR_LIT>' : True , } , <EOL> { '<STR_LIT>' : '<STR_LIT>' , } , <EOL> ] <EOL> mock_get_marathon_steps . return_value = [ <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> ] <EOL> actual = deployments_check ( service = '<STR_LIT>' , soa_dir = '<STR_LIT>' ) <EOL> assert actual is True <EOL> @ patch ( '<STR_LIT>' , new_callable = StringIO ) <EOL> @ patch ( '<STR_LIT>' ) <EOL> @ patch ( '<STR_LIT>' ) <EOL> def test_marathon_deployments_deploy_but_not_marathon ( <EOL> mock_get_marathon_steps , <EOL> mock_get_pipeline_config , <EOL> mock_stdout , <EOL> ) : <EOL> mock_get_pipeline_config . return_value = [ <EOL> { '<STR_LIT>' : '<STR_LIT>' , } , <EOL> { '<STR_LIT>' : '<STR_LIT>' , } , <EOL> { '<STR_LIT>' : '<STR_LIT>' , } , <EOL> { '<STR_LIT>' : '<STR_LIT>' , '<STR_LIT>' : True , } , <EOL> { '<STR_LIT>' : '<STR_LIT>' , } , <EOL> { '<STR_LIT>' : '<STR_LIT>' , } , <EOL> ] <EOL> mock_get_marathon_steps . return_value = [ <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> ] <EOL> actual = deployments_check ( service = '<STR_LIT>' , soa_dir = '<STR_LIT>' ) <EOL> assert actual is False <EOL> assert '<STR_LIT>' in mock_stdout . getvalue ( ) <EOL> @ patch ( '<STR_LIT>' , new_callable = StringIO ) <EOL> @ patch ( '<STR_LIT>' ) <EOL> @ patch ( '<STR_LIT>' ) <EOL> def test_marathon_deployments_marathon_but_not_deploy ( <EOL> mock_get_marathon_steps , <EOL> mock_get_pipeline_config , <EOL> mock_stdout , <EOL> ) : <EOL> mock_get_pipeline_config . return_value = [ <EOL> { '<STR_LIT>' : '<STR_LIT>' , } , <EOL> { '<STR_LIT>' : '<STR_LIT>' , } , <EOL> { '<STR_LIT>' : '<STR_LIT>' , } , <EOL> { '<STR_LIT>' : '<STR_LIT>' , '<STR_LIT>' : True , } , <EOL> { '<STR_LIT>' : '<STR_LIT>' , } , <EOL> ] <EOL> mock_get_marathon_steps . return_value = [ <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> ] <EOL> actual = deployments_check ( service = '<STR_LIT>' , soa_dir = '<STR_LIT>' ) <EOL> assert actual is False <EOL> assert '<STR_LIT>' in mock_stdout . getvalue ( ) <EOL> def test_makefile_check ( ) : <EOL> fake_makefile_path = '<STR_LIT>' <EOL> fake_contents = "<STR_LIT>" <EOL> with contextlib . nested ( <EOL> patch ( <EOL> '<STR_LIT>' , <EOL> autospec = True , <EOL> return_value = fake_contents <EOL> ) , <EOL> patch ( <EOL> '<STR_LIT>' , <EOL> ) , <EOL> patch ( <EOL> '<STR_LIT>' , <EOL> ) , <EOL> patch ( <EOL> '<STR_LIT>' , <EOL> ) , <EOL> patch ( <EOL> '<STR_LIT>' , <EOL> autospec = True , <EOL> return_value = fake_makefile_path <EOL> ) , <EOL> ) as ( <EOL> mock_get_file_contents , <EOL> mock_makefile_has_a_tab , <EOL> mock_makefile_responds_to , <EOL> mock_makefile_has_docker_tag , <EOL> mock_is_file_in_dir , <EOL> ) : <EOL> makefile_check ( ) <EOL> assert mock_makefile_has_a_tab . call_count == <NUM_LIT:1> <EOL> calls = [ call ( '<STR_LIT:test>' ) , call ( '<STR_LIT>' ) , call ( '<STR_LIT>' ) ] <EOL> mock_makefile_responds_to . assert_has_calls ( calls , any_order = True ) <EOL> assert mock_makefile_has_docker_tag . call_count == <NUM_LIT:1> </s>
