Skip to content

Commit

Permalink
[App] Fix hanging CI (#15913)
Browse files Browse the repository at this point in the history
  • Loading branch information
ethanwharris authored Dec 6, 2022
1 parent 32cf1fa commit ab022ac
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
1 change: 0 additions & 1 deletion src/lightning_app/cli/lightning_cli_delete.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
17 changes: 11 additions & 6 deletions tests/tests_app/cli/test_cmd_cli_delete.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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(
Expand All @@ -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(
Expand All @@ -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 = [
Expand All @@ -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 = [
Expand Down

0 comments on commit ab022ac

Please sign in to comment.