<s> from contextlib import nested <EOL> import mock <EOL> from pytest import raises <EOL> from paasta_tools . cli . fsm import autosuggest <EOL> class TestGetSmartstackProxyPortFromFile : <EOL> def test_multiple_stanzas_per_file ( self ) : <EOL> with nested ( <EOL> mock . patch ( "<STR_LIT>" , autospec = True ) , <EOL> mock . patch ( "<STR_LIT>" , autospec = True ) , <EOL> ) as ( <EOL> mock_open , <EOL> mock_yaml , <EOL> ) : <EOL> mock_yaml . load . return_value = { <EOL> "<STR_LIT>" : { <EOL> "<STR_LIT>" : <NUM_LIT:1> , <EOL> } , <EOL> "<STR_LIT:foo>" : { <EOL> "<STR_LIT>" : <NUM_LIT:2> , <EOL> } , <EOL> } <EOL> actual = autosuggest . _get_smartstack_proxy_port_from_file ( <EOL> "<STR_LIT>" , <EOL> "<STR_LIT>" , <EOL> ) <EOL> assert actual == <NUM_LIT:2> <EOL> class TestSuggestSmartstackProxyPort : <EOL> def test_suggest_smartstack_proxy_port ( self ) : <EOL> yelpsoa_config_root = "<STR_LIT>" <EOL> walk_return = [ <EOL> ( "<STR_LIT>" , "<STR_LIT>" , [ "<STR_LIT>" ] ) , <EOL> ( "<STR_LIT>" , "<STR_LIT>" , [ "<STR_LIT>" ] ) , <EOL> ( "<STR_LIT>" , "<STR_LIT>" , [ "<STR_LIT>" ] ) , <EOL> ] <EOL> mock_walk = mock . Mock ( return_value = walk_return ) <EOL> get_smartstack_proxy_port_from_file_returns = [ <EOL> <NUM_LIT> , <EOL> <NUM_LIT> , <EOL> <NUM_LIT> , <EOL> ] <EOL> def get_smarstack_proxy_port_from_file_side_effect ( * args ) : <EOL> return get_smartstack_proxy_port_from_file_returns . pop ( <NUM_LIT:0> ) <EOL> mock_get_smartstack_proxy_port_from_file = mock . Mock ( side_effect = get_smarstack_proxy_port_from_file_side_effect ) <EOL> with nested ( <EOL> mock . patch ( "<STR_LIT>" , mock_walk ) , <EOL> mock . patch ( "<STR_LIT>" , <EOL> mock_get_smartstack_proxy_port_from_file ) , <EOL> ) : <EOL> actual = autosuggest . suggest_smartstack_proxy_port ( yelpsoa_config_root , range_min = <NUM_LIT> , range_max = <NUM_LIT> ) <EOL> assert mock_get_smartstack_proxy_port_from_file . call_count == <NUM_LIT:3> <EOL> assert actual == <NUM_LIT> <EOL> def test_suggest_smartstack_proxy_port_too_many_services ( self ) : <EOL> """<STR_LIT>""" <EOL> yelpsoa_config_root = "<STR_LIT>" <EOL> walk_return = [ <EOL> ( "<STR_LIT>" , "<STR_LIT>" , [ "<STR_LIT>" ] ) , <EOL> ( "<STR_LIT>" , "<STR_LIT>" , [ "<STR_LIT>" ] ) , <EOL> ( "<STR_LIT>" , "<STR_LIT>" , [ "<STR_LIT>" ] ) , <EOL> ] <EOL> mock_walk = mock . Mock ( return_value = walk_return ) <EOL> get_smartstack_proxy_port_from_file_returns = [ <EOL> <NUM_LIT> , <EOL> <NUM_LIT> , <EOL> <NUM_LIT> , <EOL> ] <EOL> def get_smarstack_proxy_port_from_file_side_effect ( * args ) : <EOL> return get_smartstack_proxy_port_from_file_returns . pop ( <NUM_LIT:0> ) <EOL> mock_get_smartstack_proxy_port_from_file = mock . Mock ( side_effect = get_smarstack_proxy_port_from_file_side_effect ) <EOL> with nested ( <EOL> mock . patch ( "<STR_LIT>" , mock_walk ) , <EOL> mock . patch ( "<STR_LIT>" , <EOL> mock_get_smartstack_proxy_port_from_file ) , <EOL> ) : <EOL> with raises ( Exception ) as exc : <EOL> autosuggest . suggest_smartstack_proxy_port ( yelpsoa_config_root , range_min = <NUM_LIT> , <EOL> range_max = <NUM_LIT> ) <EOL> assert "<STR_LIT>" == str ( exc . value ) </s>
