Skip to content

Commit

Permalink
Tests cleanup for snow ws migrate (#1524)
Browse files Browse the repository at this point in the history
* 1

* Fixes

* Fixes
  • Loading branch information
sfc-gh-jsikorski authored Sep 2, 2024
1 parent 744fa09 commit 41ebb8e
Show file tree
Hide file tree
Showing 21 changed files with 39 additions and 109 deletions.
2 changes: 1 addition & 1 deletion src/snowflake/cli/api/project/definition_conversion.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ def _check_if_project_definition_meets_requirements(
)
if pd.native_app:
raise ClickException(
"Your project file contains a native app definition. Conversion Native apps is not yet supported"
"Your project file contains a native app definition. Conversion of Native apps is not yet supported"
)


Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,18 @@
definition_version: 2
entities:
test_streamlit:
artifacts:
- streamlit_app.py
- environment.yml
- pages
identifier:
name: test_streamlit
main_file: streamlit_app.py
pages_dir: None
query_warehouse: test_warehouse
stage: streamlit
title: My Fancy Streamlit
type: streamlit
test_procedure:
artifacts:
- app/
Expand Down

This file was deleted.

16 changes: 0 additions & 16 deletions tests/test_data/projects/migration_snowpark_v1_to_v2/app.py

This file was deleted.

This file was deleted.

23 changes: 0 additions & 23 deletions tests/test_data/projects/migration_snowpark_v1_to_v2/snowflake.yml

This file was deleted.

This file was deleted.

15 changes: 0 additions & 15 deletions tests/test_data/projects/migration_streamlit_V2/snowflake.yml

This file was deleted.

Empty file.
16 changes: 0 additions & 16 deletions tests/test_data/projects/migration_streamlit_v1_to_v2/app.py

This file was deleted.

This file was deleted.

Empty file.

This file was deleted.

Empty file.
9 changes: 9 additions & 0 deletions tests/workspace/__snapshots__/test_manager.ambr
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,15 @@

'''
# ---
# name: test_migrating_native_app_raises_error
'''
+- Error ----------------------------------------------------------------------+
| Your project file contains a native app definition. Conversion of Native |
| apps is not yet supported |
+------------------------------------------------------------------------------+

'''
# ---
# name: test_migration_v1_to_v2[migration_snowpark_V1_to_V2]
'''
definition_version: '2'
Expand Down
39 changes: 16 additions & 23 deletions tests/workspace/test_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,31 +84,25 @@ def test_bundle_of_invalid_entity_type(temp_dir):
ws_manager.perform_action("app", EntityActions.BUNDLE)


@pytest.mark.parametrize(
"project_directory_name",
["migration_streamlit_v1_to_v2", "migration_snowpark_v1_to_v2"],
)
def test_migration_v1_to_v2(
runner, project_directory, snapshot, project_directory_name
def test_migration_already_v2(
runner,
project_directory,
):
with project_directory(project_directory_name):
with project_directory("migration_already_v2"):
result = runner.invoke(["ws", "migrate"])

assert result.exit_code == 0
assert "Project definition migrated to version 2." in result.output
assert Path("snowflake.yml").read_text() == snapshot
assert Path("snowflake_V1.yml").read_text() == snapshot
assert "Project definition is already at version 2." in result.output


@pytest.mark.parametrize(
"project_directory_name", ["migration_streamlit_V2", "migration_snowpark_V2"]
)
def test_migration_already_v2(runner, project_directory, project_directory_name):
with project_directory(project_directory_name):
def test_migrations_with_multiple_entities(
runner, project_directory, os_agnostic_snapshot
):
with project_directory("migration_multiple_entities"):
result = runner.invoke(["ws", "migrate"])

assert result.exit_code == 0
assert "Project definition is already at version 2." in result.output
assert Path("snowflake.yml").read_text() == os_agnostic_snapshot
assert Path("snowflake_V1.yml").read_text() == os_agnostic_snapshot


@pytest.mark.parametrize(
Expand Down Expand Up @@ -149,11 +143,10 @@ def test_migration_with_only_envs(project_directory, runner):
assert result.exit_code == 0


def test_migrations_with_multiple_entities(
runner, project_directory, os_agnostic_snapshot
def test_migrating_native_app_raises_error(
project_directory, runner, os_agnostic_snapshot
):
with project_directory("migration_multiple_entities"):
with project_directory("napp_project_1") as pd:
result = runner.invoke(["ws", "migrate"])
assert result.exit_code == 0
assert Path("snowflake.yml").read_text() == os_agnostic_snapshot
assert Path("snowflake_V1.yml").read_text() == os_agnostic_snapshot
assert result.exit_code == 1
assert result.output == os_agnostic_snapshot

0 comments on commit 41ebb8e

Please sign in to comment.