From ab022ac60fcb44c10bfc32c042c5ca204ac655d1 Mon Sep 17 00:00:00 2001 From: Ethan Harris Date: Tue, 6 Dec 2022 00:21:44 +0000 Subject: [PATCH] [App] Fix hanging CI (#15913) --- src/lightning_app/cli/lightning_cli_delete.py | 1 - tests/tests_app/cli/test_cmd_cli_delete.py | 17 +++++++++++------ 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/src/lightning_app/cli/lightning_cli_delete.py b/src/lightning_app/cli/lightning_cli_delete.py index 675749c66dbd3..1664022e51c15 100644 --- a/src/lightning_app/cli/lightning_cli_delete.py +++ b/src/lightning_app/cli/lightning_cli_delete.py @@ -56,7 +56,6 @@ def _find_cluster_for_user(app_name: str, cluster_id: Optional[str]) -> str: valid_cluster_list.append(cluster.id) if cluster.spec.cluster_type == V1ClusterType.GLOBAL and default_cluster is None: default_cluster = cluster.id - break # when no cluster-id is passed in, use the default (Lightning Cloud) cluster if cluster_id is None: diff --git a/tests/tests_app/cli/test_cmd_cli_delete.py b/tests/tests_app/cli/test_cmd_cli_delete.py index 438ef064abad4..7edca4ccd7462 100644 --- a/tests/tests_app/cli/test_cmd_cli_delete.py +++ b/tests/tests_app/cli/test_cmd_cli_delete.py @@ -8,9 +8,10 @@ @pytest.mark.skipif(sys.platform == "win32", reason="currently not supported for windows.") -@mock.patch("lightning_app.cli.lightning_cli_delete.AWSClusterManager.list_clusters") +@mock.patch("lightning_cloud.login.Auth.authenticate", mock.MagicMock()) +@mock.patch("lightning_app.utilities.network.LightningClient.cluster_service_list_clusters") def test_find_cluster_for_user_when_provided_valid_cluster_id(list_clusters_mock: mock.MagicMock): - list_clusters_mock.return_value = [ + list_clusters_mock.return_value.clusters = [ Externalv1Cluster( id="default", spec=V1ClusterSpec( @@ -29,9 +30,10 @@ def test_find_cluster_for_user_when_provided_valid_cluster_id(list_clusters_mock @pytest.mark.skipif(sys.platform == "win32", reason="currently not supported for windows.") -@mock.patch("lightning_app.cli.lightning_cli_delete.AWSClusterManager.list_clusters") +@mock.patch("lightning_cloud.login.Auth.authenticate", mock.MagicMock()) +@mock.patch("lightning_app.utilities.network.LightningClient.cluster_service_list_clusters") def test_find_cluster_for_user_without_cluster_id_uses_default(list_clusters_mock: mock.MagicMock): - list_clusters_mock.return_value = [ + list_clusters_mock.return_value.clusters = [ Externalv1Cluster( id="default", spec=V1ClusterSpec( @@ -44,13 +46,14 @@ def test_find_cluster_for_user_without_cluster_id_uses_default(list_clusters_moc @pytest.mark.skipif(sys.platform == "win32", reason="currently not supported for windows.") -@mock.patch("lightning_app.cli.lightning_cli_delete.AWSClusterManager.list_clusters") +@mock.patch("lightning_cloud.login.Auth.authenticate", mock.MagicMock()) +@mock.patch("lightning_app.utilities.network.LightningClient.cluster_service_list_clusters") @mock.patch("lightning_app.cli.lightning_cli_delete.inquirer") def test_find_cluster_for_user_without_valid_cluster_id_asks_if_they_meant_to_use_valid( list_clusters_mock: mock.MagicMock, inquirer_mock: mock.MagicMock, ): - list_clusters_mock.return_value = [ + list_clusters_mock.return_value.clusters = [ Externalv1Cluster( id="default", spec=V1ClusterSpec( @@ -63,6 +66,7 @@ def test_find_cluster_for_user_without_valid_cluster_id_asks_if_they_meant_to_us @pytest.mark.skipif(sys.platform == "win32", reason="currently not supported for windows.") +@mock.patch("lightning_cloud.login.Auth.authenticate", mock.MagicMock()) @mock.patch("lightning_app.cli.lightning_cli_delete._AppManager.list_apps") def test_app_find_selected_app_instance_id_when_app_name_exists(list_apps_mock: mock.MagicMock): list_apps_mock.return_value = [ @@ -74,6 +78,7 @@ def test_app_find_selected_app_instance_id_when_app_name_exists(list_apps_mock: @pytest.mark.skipif(sys.platform == "win32", reason="currently not supported for windows.") +@mock.patch("lightning_cloud.login.Auth.authenticate", mock.MagicMock()) @mock.patch("lightning_app.cli.lightning_cli_delete._AppManager.list_apps") def test_app_find_selected_app_instance_id_when_app_id_exists(list_apps_mock: mock.MagicMock): list_apps_mock.return_value = [