diff --git a/src/snowflake/cli/_plugins/workspace/commands.py b/src/snowflake/cli/_plugins/workspace/commands.py index 5b161b71a7..ec4c34b7f8 100644 --- a/src/snowflake/cli/_plugins/workspace/commands.py +++ b/src/snowflake/cli/_plugins/workspace/commands.py @@ -100,9 +100,7 @@ def deploy( """ Deploys the specified entity. """ - - has_paths = paths is not None and len(paths) > 0 - if prune is None and recursive is None and not has_paths: + if prune is None and recursive is None and not paths: prune = True recursive = True else: @@ -111,7 +109,7 @@ def deploy( if recursive is None: recursive = False - if has_paths and prune: + if paths and prune: raise IncompatibleParametersError(["paths", "--prune"]) cli_context = get_cli_context() diff --git a/tests_integration/nativeapp/test_bundle.py b/tests_integration/nativeapp/test_bundle.py index c87c922d5e..30164200eb 100644 --- a/tests_integration/nativeapp/test_bundle.py +++ b/tests_integration/nativeapp/test_bundle.py @@ -15,6 +15,7 @@ import os import os.path import yaml +from shlex import split from tests.project.fixtures import * from tests_integration.test_utils import enable_definition_v2_feature_flag @@ -38,10 +39,10 @@ def template_setup(runner, nativeapp_project_directory, request): # Vanilla bundle on the unmodified template if command.startswith("ws"): execute_bundle_command = lambda: runner.invoke_with_connection( - command.split() + split(command) ) else: - execute_bundle_command = lambda: runner.invoke_json(command.split()) + execute_bundle_command = lambda: runner.invoke_json(split(command)) result = execute_bundle_command() assert result.exit_code == 0 diff --git a/tests_integration/nativeapp/test_deploy.py b/tests_integration/nativeapp/test_deploy.py index 38ca5cc09b..187cbf63f2 100644 --- a/tests_integration/nativeapp/test_deploy.py +++ b/tests_integration/nativeapp/test_deploy.py @@ -13,7 +13,7 @@ # limitations under the License. import os -import uuid +from shlex import split from snowflake.cli.api.project.util import TEST_RESOURCE_SUFFIX_VAR from tests.nativeapp.utils import touch @@ -68,7 +68,7 @@ def test_nativeapp_deploy( ): project_name = "myapp" with nativeapp_project_directory(test_project): - result = runner.invoke_with_connection(command.split()) + result = runner.invoke_with_connection(split(command)) assert result.exit_code == 0 assert sanitize_deploy_output(result.output) == snapshot @@ -102,7 +102,7 @@ def test_nativeapp_deploy( ) # re-deploying should be a no-op; make sure we don't issue any PUT commands - result = runner.invoke_with_connection([*command.split(), "--debug"]) + result = runner.invoke_with_connection([*split(command), "--debug"]) assert result.exit_code == 0 assert "Successfully uploaded chunk 0 of file" not in result.output @@ -193,7 +193,7 @@ def test_nativeapp_deploy_prune( os.remove(os.path.join("app", "README.md")) # deploy - result = runner.invoke_with_connection(command.split()) + result = runner.invoke_with_connection(split(command)) assert result.exit_code == 0 assert sanitize_deploy_output(result.output) == snapshot @@ -236,7 +236,7 @@ def test_nativeapp_deploy_files( # sync only two specific files to stage result = runner.invoke_with_connection( [ - *command.split(), + *split(command), "app/manifest.yml", "app/setup_script.sql", ] @@ -283,7 +283,7 @@ def test_nativeapp_deploy_nested_directories( touch("app/nested/dir/file.txt") result = runner.invoke_with_connection( - [*command.split(), "app/nested/dir/file.txt"] + [*split(command), "app/nested/dir/file.txt"] ) assert result.exit_code == 0 assert sanitize_deploy_output(result.output) == snapshot @@ -322,13 +322,13 @@ def test_nativeapp_deploy_directory( with nativeapp_project_directory(test_project): touch("app/dir/file.txt") result = runner.invoke_with_connection( - [*command.split(), "app/dir", "--no-recursive"] + [*split(command), "app/dir", "--no-recursive"] ) assert_that_result_failed_with_message_containing( result, "Add the -r flag to deploy directories." ) - result = runner.invoke_with_connection([*command.split(), "app/dir", "-r"]) + result = runner.invoke_with_connection([*split(command), "app/dir", "-r"]) assert result.exit_code == 0 package_name = f"{project_name}_pkg_{default_username}{resource_suffix}".upper() @@ -358,7 +358,7 @@ def test_nativeapp_deploy_directory_no_recursive( ): with nativeapp_project_directory(test_project): touch("app/nested/dir/file.txt") - result = runner.invoke_with_connection_json([*command.split(), "app/nested"]) + result = runner.invoke_with_connection_json([*split(command), "app/nested"]) assert result.exit_code == 1, result.output @@ -380,9 +380,7 @@ def test_nativeapp_deploy_unknown_path( runner, ): with nativeapp_project_directory(test_project): - result = runner.invoke_with_connection_json( - [*command.split(), "does_not_exist"] - ) + result = runner.invoke_with_connection_json([*split(command), "does_not_exist"]) assert result.exit_code == 1 assert "The following path does not exist:" in result.output @@ -405,7 +403,7 @@ def test_nativeapp_deploy_path_with_no_mapping( runner, ): with nativeapp_project_directory(test_project): - result = runner.invoke_with_connection_json([*command.split(), "snowflake.yml"]) + result = runner.invoke_with_connection_json([*split(command), "snowflake.yml"]) assert result.exit_code == 1 assert "No artifact found for" in result.output @@ -430,7 +428,7 @@ def test_nativeapp_deploy_rejects_pruning_when_path_is_specified( with nativeapp_project_directory(test_project): os.unlink("app/README.md") result = runner.invoke_with_connection_json( - [*command.split(), "app/README.md", "--prune"] + [*split(command), "app/README.md", "--prune"] ) assert_that_result_is_usage_error( @@ -463,7 +461,7 @@ def test_nativeapp_deploy_looks_for_prefix_matches( ): project_name = "myapp" with nativeapp_project_directory(test_project): - result = runner.invoke_with_connection([*command.split(), "-r", "app"]) + result = runner.invoke_with_connection([*split(command), "-r", "app"]) assert result.exit_code == 0 assert sanitize_deploy_output(result.output) == snapshot @@ -481,7 +479,7 @@ def test_nativeapp_deploy_looks_for_prefix_matches( ) result = runner.invoke_with_connection( - [*command.split(), "-r", "lib/parent/child/c"] + [*split(command), "-r", "lib/parent/child/c"] ) assert result.exit_code == 0 stage_files = runner.invoke_with_connection_json( @@ -498,7 +496,7 @@ def test_nativeapp_deploy_looks_for_prefix_matches( ) result = runner.invoke_with_connection( - [*command.split(), "lib/parent/child/a.py"] + [*split(command), "lib/parent/child/a.py"] ) assert result.exit_code == 0 stage_files = runner.invoke_with_connection_json( @@ -514,7 +512,7 @@ def test_nativeapp_deploy_looks_for_prefix_matches( stage_files.json, {"name": "stage/parent-lib/child/b.py"} ) - result = runner.invoke_with_connection([*command.split(), "lib", "-r"]) + result = runner.invoke_with_connection([*split(command), "lib", "-r"]) assert result.exit_code == 0 stage_files = runner.invoke_with_connection_json( ["stage", "list-files", f"{package_name}.{stage_name}"] @@ -554,7 +552,7 @@ def test_nativeapp_deploy_dot( ): project_name = "myapp" with nativeapp_project_directory(test_project): - result = runner.invoke_with_connection([*command.split(), "-r", "."]) + result = runner.invoke_with_connection([*split(command), "-r", "."]) assert result.exit_code == 0 assert sanitize_deploy_output(result.output) == snapshot