<s> import mock <EOL> from pytest import raises <EOL> from pytest import yield_fixture <EOL> import paasta_tools . cli . cmds . fsm as fsm <EOL> from paasta_tools . cli . fsm . questions import _yamlize <EOL> from paasta_tools . cli . fsm . service import SrvReaderWriter <EOL> from paasta_tools . utils import SystemPaastaConfig <EOL> class ValidateOptionsTest : <EOL> @ yield_fixture <EOL> def mock_exists ( self ) : <EOL> with mock . patch ( "<STR_LIT>" ) as mock_exists : <EOL> mock_exists . return_value = True <EOL> yield mock_exists <EOL> def test_yelpsoa_config_root_exists ( self , mock_exists ) : <EOL> parser = mock . Mock ( ) <EOL> args = mock . Mock ( ) <EOL> args . yelpsoa_config_root = "<STR_LIT>" <EOL> mock_exists . return_value = False <EOL> with raises ( SystemExit ) as err : <EOL> fsm . validate_args ( parser , args ) <EOL> assert ( "<STR_LIT>" <EOL> "<STR_LIT>" % args . yelpsoa_config_root ) in err <EOL> class TestGetPaastaConfig : <EOL> @ yield_fixture <EOL> def mock_get_srvname ( self ) : <EOL> with ( <EOL> mock . patch ( "<STR_LIT>" , autospec = True ) <EOL> ) as mock_get_srvname : <EOL> yield mock_get_srvname <EOL> @ yield_fixture <EOL> def mock_get_service_stanza ( self ) : <EOL> with ( <EOL> mock . patch ( "<STR_LIT>" , autospec = True ) <EOL> ) as mock_get_service_stanza : <EOL> yield mock_get_service_stanza <EOL> @ yield_fixture <EOL> def mock_get_smartstack_stanza ( self ) : <EOL> with ( <EOL> mock . patch ( "<STR_LIT>" , autospec = True ) <EOL> ) as mock_get_smartstack_stanza : <EOL> yield mock_get_smartstack_stanza <EOL> @ yield_fixture <EOL> def mock_get_marathon_stanza ( self ) : <EOL> with ( <EOL> mock . patch ( "<STR_LIT>" , autospec = True ) <EOL> ) as mock_get_marathon_stanza : <EOL> yield mock_get_marathon_stanza <EOL> @ yield_fixture <EOL> def mock_get_monitoring_stanza ( self ) : <EOL> with ( <EOL> mock . patch ( "<STR_LIT>" , autospec = True ) <EOL> ) as mock_get_monitoring_stanza : <EOL> yield mock_get_monitoring_stanza <EOL> @ yield_fixture <EOL> def mock_get_paasta_config ( self ) : <EOL> with ( <EOL> mock . patch ( "<STR_LIT>" , autospec = True ) <EOL> ) as mock_get_paasta_config : <EOL> yield mock_get_paasta_config <EOL> def test_everything_specified ( <EOL> self , <EOL> mock_get_srvname , <EOL> mock_get_service_stanza , <EOL> mock_get_smartstack_stanza , <EOL> mock_get_marathon_stanza , <EOL> mock_get_monitoring_stanza , <EOL> mock_get_paasta_config , <EOL> ) : <EOL> """<STR_LIT>""" <EOL> yelpsoa_config_root = "<STR_LIT>" <EOL> srvname = "<STR_LIT>" <EOL> auto = "<STR_LIT>" <EOL> port = <NUM_LIT> <EOL> team = "<STR_LIT>" <EOL> description = '<STR_LIT>' <EOL> external_link = '<STR_LIT>' <EOL> fsm . get_paasta_config ( yelpsoa_config_root , srvname , auto , port , team , description , external_link ) <EOL> mock_get_srvname . assert_called_once_with ( srvname , auto ) <EOL> mock_get_service_stanza . assert_called_once_with ( description , external_link , auto ) <EOL> mock_get_smartstack_stanza . assert_called_once_with ( yelpsoa_config_root , auto , port ) <EOL> mock_get_marathon_stanza . assert_called_once_with ( ) <EOL> mock_get_monitoring_stanza . assert_called_once_with ( auto , team ) <EOL> mock_get_paasta_config . assert_called_once_with ( ) <EOL> class TestWritePaastaConfig : <EOL> @ yield_fixture <EOL> def mock_srv ( self ) : <EOL> mock_srv = mock . Mock ( ) <EOL> mock_srv . io = mock . Mock ( spec_set = SrvReaderWriter ) <EOL> yield mock_srv <EOL> @ yield_fixture <EOL> def test_paasta_config ( self ) : <EOL> test_paasta_config = SystemPaastaConfig ( <EOL> config = { <EOL> '<STR_LIT>' : { <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' <EOL> } , <EOL> '<STR_LIT>' : { <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> } , <EOL> } , <EOL> directory = '<STR_LIT>' , <EOL> ) <EOL> yield test_paasta_config <EOL> def test ( self , mock_srv , test_paasta_config ) : <EOL> service_stanza = { '<STR_LIT:foo>' : '<STR_LIT:bar>' } <EOL> smartstack_stanza = { '<STR_LIT>' : '<STR_LIT>' } <EOL> monitoring_stanza = { '<STR_LIT>' : '<STR_LIT>' } <EOL> deploy_stanza = { '<STR_LIT>' : '<STR_LIT>' } <EOL> marathon_stanza = ( <EOL> ( ( '<STR_LIT>' , '<STR_LIT>' ) ) , <EOL> ( ( '<STR_LIT>' , '<STR_LIT>' ) ) , <EOL> ( ( '<STR_LIT>' , '<STR_LIT>' ) ) , <EOL> ) <EOL> fsm . write_paasta_config ( <EOL> mock_srv , <EOL> service_stanza , <EOL> smartstack_stanza , <EOL> monitoring_stanza , <EOL> test_paasta_config . get_fsm_deploy_pipeline ( ) , <EOL> marathon_stanza , <EOL> test_paasta_config . get_fsm_cluster_map ( ) , <EOL> ) <EOL> mock_srv . io . write_file . assert_any_call ( <EOL> '<STR_LIT>' , <EOL> _yamlize ( smartstack_stanza ) , <EOL> ) <EOL> mock_srv . io . write_file . assert_any_call ( <EOL> '<STR_LIT>' , <EOL> _yamlize ( service_stanza ) , <EOL> ) <EOL> mock_srv . io . write_file . assert_any_call ( <EOL> '<STR_LIT>' , <EOL> _yamlize ( monitoring_stanza ) , <EOL> ) <EOL> mock_srv . io . write_file . assert_any_call ( <EOL> '<STR_LIT>' , <EOL> _yamlize ( deploy_stanza ) , <EOL> ) <EOL> for ( filename , stanza ) in marathon_stanza : <EOL> mock_srv . io . write_file . assert_any_call ( <EOL> '<STR_LIT>' % filename , <EOL> _yamlize ( stanza ) , <EOL> ) <EOL> for ( clustername , filename ) in test_paasta_config . get_fsm_cluster_map ( ) . items ( ) : <EOL> mock_srv . io . symlink_file_relative . assert_any_call ( <EOL> '<STR_LIT>' % filename , <EOL> '<STR_LIT>' % clustername , <EOL> ) </s>
