def test_report_cluster_status(mock_stdout, mock_load_system_paasta_config):
    cluster = 'fake_cluster'

    fake_system_paasta_config = SystemPaastaConfig(
        {
            'dashboard_links': {
                'fake_cluster': {
                    'URL': 'http://paasta-fake_cluster.yelp:5050',
                },
            },
        }, 'fake_directory')

    mock_load_system_paasta_config.return_value = fake_system_paasta_config

    thing_to_patch = 'paasta_tools.cli.cmds.metastatus.execute_paasta_metastatus_on_remote_master'
    with mock.patch(
            thing_to_patch) as mock_execute_paasta_metastatus_on_remote_master:
        mock_execute_paasta_metastatus_on_remote_master.return_value = 'mock_status'
        metastatus.print_cluster_status(cluster, fake_system_paasta_config)
        mock_execute_paasta_metastatus_on_remote_master.assert_called_once_with(
            cluster,
            fake_system_paasta_config,
            verbose=False,
        )
        actual = mock_stdout.getvalue()
        assert 'Cluster: %s' % cluster in actual
        assert 'mock_status' in actual
def test_report_cluster_status(mock_stdout, mock_load_system_paasta_config):
    cluster = 'fake_cluster'

    fake_system_paasta_config = SystemPaastaConfig({
        'dashboard_links': {
            'fake_cluster': {
                'URL': 'http://paasta-fake_cluster.yelp:5050',
            },
        },
    }, 'fake_directory')

    mock_load_system_paasta_config.return_value = fake_system_paasta_config

    thing_to_patch = 'paasta_tools.cli.cmds.metastatus.execute_paasta_metastatus_on_remote_master'
    with mock.patch(thing_to_patch) as mock_execute_paasta_metastatus_on_remote_master:
        mock_execute_paasta_metastatus_on_remote_master.return_value = 'mock_status'
        metastatus.print_cluster_status(
            cluster,
            fake_system_paasta_config,
            False,
            [],
            verbose=0
        )
        mock_execute_paasta_metastatus_on_remote_master.assert_called_once_with(
            cluster=cluster,
            system_paasta_config=fake_system_paasta_config,
            humanize=False,
            groupings=[],
            verbose=0,
        )
        actual = mock_stdout.getvalue()
        assert 'Cluster: %s' % cluster in actual
        assert 'mock_status' in actual
def test_report_cluster_status(mock_stdout):
    cluster = 'fake_cluster'
    thing_to_patch = 'paasta_tools.cli.cmds.metastatus.execute_paasta_metastatus_on_remote_master'
    with mock.patch(thing_to_patch) as mock_execute_paasta_metastatus_on_remote_master:
        mock_execute_paasta_metastatus_on_remote_master.return_value = 'mock_status'
        metastatus.print_cluster_status(cluster)
        mock_execute_paasta_metastatus_on_remote_master.assert_called_once_with(
            cluster, False
        )
        actual = mock_stdout.getvalue()
        assert 'Cluster: %s' % cluster in actual
        assert 'mock_status' in actual
def test_report_cluster_status(mock_load_system_paasta_config, capfd):
    cluster = 'fake_cluster'

    fake_system_paasta_config = SystemPaastaConfig(
        {
            'dashboard_links': {
                'fake_cluster': {
                    'URL': 'http://paasta-fake_cluster.yelp:5050',
                },
            },
        }, 'fake_directory')

    mock_load_system_paasta_config.return_value = fake_system_paasta_config

    thing_to_patch = 'paasta_tools.cli.cmds.metastatus.execute_paasta_metastatus_on_remote_master'
    with mock.patch(
            thing_to_patch,
            autospec=True) as mock_execute_paasta_metastatus_on_remote_master:
        mock_execute_paasta_metastatus_on_remote_master.return_value = mock.sentinel.return_value, 'mock_status'
        return_code = metastatus.print_cluster_status(
            cluster, fake_system_paasta_config, False, [], verbose=0)
        mock_execute_paasta_metastatus_on_remote_master.assert_called_once_with(
            cluster=cluster,
            system_paasta_config=fake_system_paasta_config,
            humanize=False,
            groupings=[],
            verbose=0,
            autoscaling_info=False)
        actual, _ = capfd.readouterr()
        assert 'Cluster: %s' % cluster in actual
        assert 'mock_status' in actual
        assert return_code == mock.sentinel.return_value
def test_report_cluster_status(mock_load_system_paasta_config, capfd):
    cluster = "fake_cluster"

    fake_system_paasta_config = SystemPaastaConfig(
        {
            "dashboard_links": {
                "fake_cluster": {"URL": "http://paasta-fake_cluster.yelp:5050"}
            }
        },
        "fake_directory",
    )

    mock_load_system_paasta_config.return_value = fake_system_paasta_config

    thing_to_patch = (
        "paasta_tools.cli.cmds.metastatus.execute_paasta_metastatus_on_remote_master"
    )
    with mock.patch(
        thing_to_patch, autospec=True
    ) as mock_execute_paasta_metastatus_on_remote_master:
        mock_execute_paasta_metastatus_on_remote_master.return_value = (
            mock.sentinel.return_value,
            "mock_status",
        )
        return_code = metastatus.print_cluster_status(
            cluster, fake_system_paasta_config, [], verbose=0
        )
        mock_execute_paasta_metastatus_on_remote_master.assert_called_once_with(
            cluster=cluster,
            system_paasta_config=fake_system_paasta_config,
            groupings=[],
            verbose=0,
            autoscaling_info=False,
            use_mesos_cache=False,
        )
        actual, _ = capfd.readouterr()
        assert "Cluster: %s" % cluster in actual
        assert "mock_status" in actual
        assert return_code == mock.sentinel.return_value