def test_get_default_cluster_for_service_empty_deploy_config(): fake_service = "fake_service" with contextlib.nested( mock.patch("utils.list_clusters", autospec=True, return_value=[]), mock.patch("utils.load_system_paasta_config", autospec=True), ) as (mock_list_clusters, mock_load_system_paasta_config): mock_load_system_paasta_config.side_effect = utils.PaastaNotConfiguredError with raises(utils.NoConfigurationForServiceError): utils.get_default_cluster_for_service(fake_service) mock_list_clusters.assert_called_once_with(fake_service)
def test_get_default_cluster_for_service_empty_deploy_config(): fake_service = 'fake_service' with contextlib.nested( mock.patch('utils.list_clusters', autospec=True, return_value=[]), mock.patch('utils.load_system_paasta_config', autospec=True), ) as ( mock_list_clusters, mock_load_system_paasta_config, ): mock_load_system_paasta_config.side_effect = utils.PaastaNotConfiguredError with raises(utils.NoConfigurationForServiceError): utils.get_default_cluster_for_service(fake_service) mock_list_clusters.assert_called_once_with(fake_service)
def test_get_default_cluster_for_service(): fake_service = "fake_service" fake_clusters = ["fake_cluster-1", "fake_cluster-2"] with contextlib.nested( mock.patch("utils.list_clusters", autospec=True, return_value=fake_clusters), mock.patch("utils.load_system_paasta_config", autospec=True), ) as (mock_list_clusters, mock_load_system_paasta_config): mock_load_system_paasta_config.side_effect = utils.PaastaNotConfiguredError assert utils.get_default_cluster_for_service(fake_service) == "fake_cluster-1" mock_list_clusters.assert_called_once_with(fake_service)
def test_get_default_cluster_for_service(): fake_service = 'fake_service' fake_clusters = ['fake_cluster-1', 'fake_cluster-2'] with contextlib.nested( mock.patch('utils.list_clusters', autospec=True, return_value=fake_clusters), mock.patch('utils.load_system_paasta_config', autospec=True), ) as ( mock_list_clusters, mock_load_system_paasta_config, ): mock_load_system_paasta_config.side_effect = utils.PaastaNotConfiguredError assert utils.get_default_cluster_for_service( fake_service) == 'fake_cluster-1' mock_list_clusters.assert_called_once_with(fake_service)