Skip to content

Commit

Permalink
update unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
sfc-gh-gbloom committed Sep 11, 2024
1 parent c3c1981 commit b8f586e
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 10 deletions.
23 changes: 13 additions & 10 deletions tests/nativeapp/test_run_processor.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
)
from tests.nativeapp.utils import (
APP_ENTITY_GET_EXISTING_APP_INFO,
APP_ENTITY_GET_EXISTING_VERSION_INFO,
NATIVEAPP_MODULE,
SQL_EXECUTOR_EXECUTE,
TYPER_CONFIRM,
Expand Down Expand Up @@ -1758,7 +1759,7 @@ def test_upgrade_app_recreate_app(

# Test upgrade app method for version AND no existing version info
@mock.patch(
"snowflake.cli._plugins.nativeapp.run_processor.NativeAppRunProcessor.get_existing_version_info",
APP_ENTITY_GET_EXISTING_VERSION_INFO,
return_value=None,
)
@pytest.mark.parametrize(
Expand Down Expand Up @@ -1787,7 +1788,7 @@ def test_upgrade_app_from_version_throws_usage_error_one(

# Test upgrade app method for version AND no existing app package from version info
@mock.patch(
"snowflake.cli._plugins.nativeapp.run_processor.NativeAppRunProcessor.get_existing_version_info",
APP_ENTITY_GET_EXISTING_VERSION_INFO,
side_effect=ApplicationPackageDoesNotExistError("app_pkg"),
)
@pytest.mark.parametrize(
Expand Down Expand Up @@ -1816,7 +1817,7 @@ def test_upgrade_app_from_version_throws_usage_error_two(

# Test upgrade app method for version AND existing app info AND user wants to drop app AND drop succeeds AND app is created successfully
@mock.patch(
"snowflake.cli._plugins.nativeapp.run_processor.NativeAppRunProcessor.get_existing_version_info",
APP_ENTITY_GET_EXISTING_VERSION_INFO,
return_value={"key": "val"},
)
@mock.patch(SQL_EXECUTOR_EXECUTE)
Expand Down Expand Up @@ -1908,13 +1909,15 @@ def test_upgrade_app_recreate_app_from_version(
)

run_processor = _get_na_run_processor()
run_processor.process(
bundle_map=mock_bundle_map,
policy=policy_param,
version="v1",
is_interactive=True,
)
assert mock_execute.mock_calls == expected
# TODO Remove next line once ApplicationEntity.action_drop() is implemented and ApplicationEntity.create_or_upgrade_app() drop before upgrade is implemented
with pytest.raises(NotImplementedError):
run_processor.process(
bundle_map=mock_bundle_map,
policy=policy_param,
version="v1",
is_interactive=True,
)
assert mock_execute.mock_calls == expected


# Test get_existing_version_info returns version info correctly
Expand Down
1 change: 1 addition & 0 deletions tests/nativeapp/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@

APP_ENTITY = "snowflake.cli.api.entities.application_entity.ApplicationEntity"
APP_ENTITY_GET_EXISTING_APP_INFO = f"{APP_ENTITY}.get_existing_app_info"
APP_ENTITY_GET_EXISTING_VERSION_INFO = f"{APP_ENTITY}.get_existing_version_info"

APP_PACKAGE_ENTITY = (
"snowflake.cli.api.entities.application_package_entity.ApplicationPackageEntity"
Expand Down

0 comments on commit b8f586e

Please sign in to comment.