예제 #1
0
    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,
        )
예제 #2
0
    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,
        )
예제 #3
0
    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
예제 #4
0
    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
예제 #5
0
    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
예제 #6
0
    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