Пример #1
0
def test_get_deployments_strings_default_case_with_smartstack():
    with contextlib.nested(
            mock.patch('paasta_tools.cli.cmds.info.get_actual_deployments',
                       autospec=True),
            mock.patch('service_configuration_lib.read_service_configuration',
                       autospec=True),
    ) as (
            mock_get_actual_deployments,
            mock_read_service_configuration,
    ):
        mock_get_actual_deployments.return_value = [
            'clusterA.main', 'clusterB.main'
        ]
        mock_read_service_configuration.return_value = {
            'smartstack': {
                'main': {
                    'proxy_port': 9001
                }
            }
        }
        actual = info.get_deployments_strings('fake_service', '/fake/soa/dir')
        assert ' - clusterA (%s)' % PaastaColors.cyan(
            'http://fake_service.paasta-clusterA.yelp/') in actual
        assert ' - clusterB (%s)' % PaastaColors.cyan(
            'http://fake_service.paasta-clusterB.yelp/') in actual
Пример #2
0
def test_get_deployments_strings_no_deployments():
    with mock.patch(
        'paasta_tools.cli.cmds.info.get_actual_deployments', autospec=True
    ) as mock_get_actual_deployments:
        mock_get_actual_deployments.side_effect = NoDeploymentsAvailable
        actual = info.get_deployments_strings('unused', '/fake/soa/dir')
        assert 'N/A: Not deployed' in actual[0]
Пример #3
0
def test_get_deployments_strings_no_deployments():
    with mock.patch(
            'paasta_tools.cli.cmds.info.get_actual_deployments',
            autospec=True,
    ) as mock_get_actual_deployments:
        mock_get_actual_deployments.side_effect = NoDeploymentsAvailable
        actual = info.get_deployments_strings('unused', '/fake/soa/dir')
        assert 'N/A: Not deployed' in actual[0]
Пример #4
0
def test_get_deployments_strings_non_listening_service():
    with contextlib.nested(
        mock.patch('paasta_tools.cli.cmds.info.get_actual_deployments', autospec=True),
        mock.patch('paasta_tools.cli.cmds.info.load_service_namespace_config', autospec=True),
    ) as (mock_get_actual_deployments, mock_load_service_namespace_config):
        mock_get_actual_deployments.return_value = ['clusterA.main', 'clusterB.main']
        mock_load_service_namespace_config.return_value = ServiceNamespaceConfig()
        actual = info.get_deployments_strings('unused', '/fake/soa/dir')
        assert ' - clusterA (N/A)' in actual
        assert ' - clusterB (N/A)' in actual
Пример #5
0
def test_get_deployments_strings_protocol_tcp_case():
    with contextlib.nested(
        mock.patch('paasta_tools.cli.cmds.info.get_actual_deployments', autospec=True),
        mock.patch('paasta_tools.cli.cmds.info.load_service_namespace_config', autospec=True),
    ) as (mock_get_actual_deployments, mock_load_service_namespace_config):
        mock_get_actual_deployments.return_value = ['clusterA.main', 'clusterB.main']
        mock_load_service_namespace_config.return_value = ServiceNamespaceConfig({'mode': 'tcp', 'proxy_port': 8080})
        actual = info.get_deployments_strings('unused', '/fake/soa/dir')
        assert ' - clusterA (%s)' % PaastaColors.cyan('tcp://paasta-clusterA.yelp:8080/') in actual
        assert ' - clusterB (%s)' % PaastaColors.cyan('tcp://paasta-clusterB.yelp:8080/') in actual
Пример #6
0
def test_get_deployments_strings_non_listening_service():
    with contextlib.nested(
        mock.patch("paasta_tools.cli.cmds.info.get_actual_deployments", autospec=True),
        mock.patch("paasta_tools.cli.cmds.info.load_service_namespace_config", autospec=True),
    ) as (mock_get_actual_deployments, mock_load_service_namespace_config):
        mock_get_actual_deployments.return_value = ["clusterA.main", "clusterB.main"]
        mock_load_service_namespace_config.return_value = ServiceNamespaceConfig()
        actual = info.get_deployments_strings("unused")
        assert " - clusterA (N/A)" in actual
        assert " - clusterB (N/A)" in actual
Пример #7
0
def test_get_deployments_strings_protocol_tcp_case():
    with contextlib.nested(
        mock.patch("paasta_tools.cli.cmds.info.get_actual_deployments", autospec=True),
        mock.patch("paasta_tools.cli.cmds.info.load_service_namespace_config", autospec=True),
    ) as (mock_get_actual_deployments, mock_load_service_namespace_config):
        mock_get_actual_deployments.return_value = ["clusterA.main", "clusterB.main"]
        mock_load_service_namespace_config.return_value = ServiceNamespaceConfig({"mode": "tcp", "proxy_port": 8080})
        actual = info.get_deployments_strings("unused")
        assert " - clusterA (%s)" % PaastaColors.cyan("tcp://paasta-clusterA.yelp:8080/") in actual
        assert " - clusterB (%s)" % PaastaColors.cyan("tcp://paasta-clusterB.yelp:8080/") in actual
Пример #8
0
def test_get_deployments_strings_default_case_with_smartstack():
    with contextlib.nested(
        mock.patch("paasta_tools.cli.cmds.info.get_actual_deployments", autospec=True),
        mock.patch("service_configuration_lib.read_service_configuration", autospec=True),
    ) as (mock_get_actual_deployments, mock_read_service_configuration):
        mock_get_actual_deployments.return_value = ["clusterA.main", "clusterB.main"]
        mock_read_service_configuration.return_value = {"smartstack": {"main": {"proxy_port": 9001}}}
        actual = info.get_deployments_strings("fake_service")
        assert " - clusterA (%s)" % PaastaColors.cyan("http://fake_service.paasta-clusterA.yelp/") in actual
        assert " - clusterB (%s)" % PaastaColors.cyan("http://fake_service.paasta-clusterB.yelp/") in actual
Пример #9
0
def test_get_deployments_strings_non_listening_service():
    with mock.patch(
            "paasta_tools.cli.cmds.info.get_actual_deployments",
            autospec=True) as mock_get_actual_deployments, mock.patch(
                "paasta_tools.cli.cmds.info.load_service_namespace_config",
                autospec=True) as mock_load_service_namespace_config:
        mock_get_actual_deployments.return_value = [
            "clusterA.main", "clusterB.main"
        ]
        mock_load_service_namespace_config.return_value = ServiceNamespaceConfig(
        )
        actual = info.get_deployments_strings("unused", "/fake/soa/dir")
        assert " - clusterA (N/A)" in actual
        assert " - clusterB (N/A)" in actual
Пример #10
0
def test_get_deployments_strings_non_listening_service():
    with mock.patch(
            'paasta_tools.cli.cmds.info.get_actual_deployments',
            autospec=True,
    ) as mock_get_actual_deployments, mock.patch(
            'paasta_tools.cli.cmds.info.load_service_namespace_config',
            autospec=True,
    ) as mock_load_service_namespace_config:
        mock_get_actual_deployments.return_value = [
            'clusterA.main', 'clusterB.main'
        ]
        mock_load_service_namespace_config.return_value = ServiceNamespaceConfig(
        )
        actual = info.get_deployments_strings('unused', '/fake/soa/dir')
        assert ' - clusterA (N/A)' in actual
        assert ' - clusterB (N/A)' in actual
Пример #11
0
def test_get_deployments_strings_default_case_with_smartstack():
    with contextlib.nested(
        mock.patch('paasta_tools.cli.cmds.info.get_actual_deployments', autospec=True),
        mock.patch('service_configuration_lib.read_service_configuration', autospec=True),
    ) as (
        mock_get_actual_deployments,
        mock_read_service_configuration,
    ):
        mock_get_actual_deployments.return_value = ['clusterA.main', 'clusterB.main']
        mock_read_service_configuration.return_value = {
            'smartstack': {
                'main': {
                    'proxy_port': 9001
                }
            }
        }
        actual = info.get_deployments_strings('fake_service', '/fake/soa/dir')
        assert ' - clusterA (%s)' % PaastaColors.cyan('http://fake_service.paasta-clusterA.yelp/') in actual
        assert ' - clusterB (%s)' % PaastaColors.cyan('http://fake_service.paasta-clusterB.yelp/') in actual
Пример #12
0
def test_get_deployments_strings_protocol_tcp_case():
    with mock.patch(
            "paasta_tools.cli.cmds.info.get_actual_deployments",
            autospec=True) as mock_get_actual_deployments, mock.patch(
                "paasta_tools.cli.cmds.info.load_service_namespace_config",
                autospec=True) as mock_load_service_namespace_config:
        mock_get_actual_deployments.return_value = [
            "clusterA.main", "clusterB.main"
        ]
        mock_load_service_namespace_config.return_value = ServiceNamespaceConfig(
            {
                "mode": "tcp",
                "proxy_port": 8080
            })
        actual = info.get_deployments_strings("unused", "/fake/soa/dir")
        assert (" - clusterA (%s)" %
                PaastaColors.cyan("tcp://paasta-clusterA.yelp:8080/")
                in actual)
        assert (" - clusterB (%s)" %
                PaastaColors.cyan("tcp://paasta-clusterB.yelp:8080/")
                in actual)
Пример #13
0
def test_get_deployments_strings_protocol_tcp_case():
    with mock.patch(
            'paasta_tools.cli.cmds.info.get_actual_deployments',
            autospec=True,
    ) as mock_get_actual_deployments, mock.patch(
            'paasta_tools.cli.cmds.info.load_service_namespace_config',
            autospec=True,
    ) as mock_load_service_namespace_config:
        mock_get_actual_deployments.return_value = [
            'clusterA.main', 'clusterB.main'
        ]
        mock_load_service_namespace_config.return_value = ServiceNamespaceConfig(
            {
                'mode': 'tcp',
                'proxy_port': 8080
            })
        actual = info.get_deployments_strings('unused', '/fake/soa/dir')
        assert ' - clusterA (%s)' % PaastaColors.cyan(
            'tcp://paasta-clusterA.yelp:8080/') in actual
        assert ' - clusterB (%s)' % PaastaColors.cyan(
            'tcp://paasta-clusterB.yelp:8080/') in actual
Пример #14
0
def test_get_deployments_strings_default_case_with_smartstack():
    with mock.patch(
            "paasta_tools.cli.cmds.info.get_actual_deployments",
            autospec=True) as mock_get_actual_deployments, mock.patch(
                "service_configuration_lib.read_extra_service_information",
                autospec=True) as mock_read_extra_service_information:
        mock_get_actual_deployments.return_value = [
            "clusterA.main", "clusterB.main"
        ]
        mock_read_extra_service_information.return_value = {
            "main": {
                "proxy_port": 9001
            }
        }

        actual = info.get_deployments_strings("fake_service", "/fake/soa/dir")
        assert (" - clusterA (%s)" %
                PaastaColors.cyan("http://fake_service.paasta-clusterA.yelp/")
                in actual)
        assert (" - clusterB (%s)" %
                PaastaColors.cyan("http://fake_service.paasta-clusterB.yelp/")
                in actual)
Пример #15
0
def test_get_deployments_strings_no_deployments():
    with mock.patch("paasta_tools.cli.cmds.info.get_actual_deployments",
                    autospec=True) as mock_get_actual_deployments:
        mock_get_actual_deployments.side_effect = NoDeploymentsAvailable
        actual = info.get_deployments_strings("unused", "/fake/soa/dir")
        assert "N/A: Not deployed" in actual[0]
Пример #16
0
def test_get_deployments_strings_no_deployments():
    with mock.patch("paasta_tools.cli.cmds.info.get_actual_deployments", autospec=True) as mock_get_actual_deployments:
        mock_get_actual_deployments.side_effect = NoDeploymentsAvailable
        actual = info.get_deployments_strings("unused")
        assert "N/A: Not deployed" in actual[0]