def test_arg_not_passed_in_auto_false(self, mock_ask, fake_suggested_port, fake_expected_stanza): """If a value is not specified and --auto was not requested, prompt the user. """ yelpsoa_config_root = "fake_yelpsoa_config_root" port = None suggested_port = 12345 auto = False mock_ask.return_value = suggested_port with mock.patch( "paasta_tools.paasta_cli.fsm.questions.suggest_smartstack_proxy_port", autospec=True, return_value=suggested_port, ) as ( mock_suggest_smartstack_proxy_port ): actual = fsm.get_smartstack_stanza(yelpsoa_config_root, auto, port) mock_suggest_smartstack_proxy_port.assert_called_once_with( yelpsoa_config_root) assert fake_expected_stanza == actual mock_ask.assert_called_once_with( mock.ANY, suggested_port, )
def test_arg_passed_in(self, mock_ask, fake_suggested_port, fake_expected_stanza): """If a port is specified, use it.""" yelpsoa_config_root = "fake_yelpsoa_config_root" port = fake_suggested_port auto = "UNUSED" actual = fsm.get_smartstack_stanza(yelpsoa_config_root, auto, port) assert fake_expected_stanza == actual assert 0 == mock_ask.call_count
def test_arg_not_passed_in_auto_true(self, mock_ask, fake_suggested_port, fake_expected_stanza): """If a value is not specified but --auto was requested, calculate and use a sane default. """ yelpsoa_config_root = "fake_yelpsoa_config_root" port = None auto = True with mock.patch( "paasta_tools.paasta_cli.fsm.questions.suggest_smartstack_proxy_port", autospec=True, return_value=fake_suggested_port, ) as ( mock_suggest_smartstack_proxy_port ): actual = fsm.get_smartstack_stanza(yelpsoa_config_root, auto, port) mock_suggest_smartstack_proxy_port.assert_called_once_with( yelpsoa_config_root) assert fake_expected_stanza == actual assert 0 == mock_ask.call_count