Skip to content

Commit

Permalink
Fixed precommit errors and tests
Browse files Browse the repository at this point in the history
  • Loading branch information
sfc-gh-astus committed Dec 6, 2024
1 parent d181eb7 commit 1748f3d
Show file tree
Hide file tree
Showing 9 changed files with 35 additions and 36 deletions.
4 changes: 3 additions & 1 deletion .github/workflows/lint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ jobs:
with:
python-version: '3.x'
- name: Install pre-commit
run: python -m pip install pre-commit tomlkit
run: python -m pip install pre-commit tomlkit ruff==0.1.7
- name: Ruff
run: ruff check --exclude "**/tests_common/,**/tests_integration/"
- name: Run pre-commit
run: pre-commit run --all-files
5 changes: 5 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ repos:
hooks:
- id: ruff
args: [--fix, --exclude, "**/tests_common/,**/tests_integration/"]
verbose: true
- repo: https://github.com/psf/black
rev: 22.12.0
hooks:
Expand All @@ -25,6 +26,10 @@ repos:
hooks:
- id: mypy
additional_dependencies: [types-pkg-resources==0.1.3, types-all==1.0.0]
exclude: >
(?x)
^tests/test_data/projects/.*|
^tests_integration/test_data/projects/.*
- repo: https://github.com/codespell-project/codespell
rev: v2.2.4
hooks:
Expand Down
2 changes: 1 addition & 1 deletion tests/nativeapp/test_artifacts.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import pytest
from click import ClickException
from snowflake.cli._plugins.nativeapp.artifacts import (
VersionInfo,
build_bundle,
find_events_definitions_in_manifest_file,
find_version_info_in_manifest_file,
Expand All @@ -29,7 +30,6 @@
NotInDeployRootError,
SourceNotFoundError,
TooManyFilesError,
VersionInfo,
)
from snowflake.cli.api.project.definition import load_project
from snowflake.cli.api.project.schemas.entities.common import PathMapping
Expand Down
18 changes: 16 additions & 2 deletions tests/snowpark/test_function.py
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,14 @@ def test_deploy_function_no_changes(
)
@mock_session_has_warehouse
def test_deploy_function_needs_update_because_packages_changes(
mock_download, mock_connector, runner, mock_ctx, mock_cursor, project_directory, project_name, enable_snowpark_glob_support_feature_flag
mock_download,
mock_connector,
runner,
mock_ctx,
mock_cursor,
project_directory,
project_name,
enable_snowpark_glob_support_feature_flag,
):
mock_download.return_value = DownloadUnavailablePackagesResult()
rows = [
Expand Down Expand Up @@ -304,7 +311,14 @@ def test_deploy_function_needs_update_because_packages_changes(
)
@mock_session_has_warehouse
def test_deploy_function_needs_update_because_handler_changes(
mock_download, mock_connector, runner, mock_ctx, mock_cursor, project_directory, project_name, enable_snowpark_glob_support_feature_flag
mock_download,
mock_connector,
runner,
mock_ctx,
mock_cursor,
project_directory,
project_name,
enable_snowpark_glob_support_feature_flag,
):
mock_download.return_value = DownloadUnavailablePackagesResult()
rows = [
Expand Down
4 changes: 2 additions & 2 deletions tests/streamlit/test_artifacts.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@
@mock.patch("snowflake.cli._plugins.snowpark.commands.StageManager.put")
@mock.patch(
"snowflake.cli._plugins.connection.util.get_ui_parameters",
return_value={UIParameter.NA_ENABLE_REGIONLESS_REDIRECT: "false"},
return_value={UIParameter.NA_ENABLE_REGIONLESS_REDIRECT: False},
)
def test_deploy_with_artifacts(
mock_param,
Expand Down Expand Up @@ -252,7 +252,7 @@ def test_deploy_with_artifacts(
@mock.patch("snowflake.cli._plugins.snowpark.commands.StageManager.put")
@mock.patch(
"snowflake.cli._plugins.connection.util.get_ui_parameters",
return_value={UIParameter.NA_ENABLE_REGIONLESS_REDIRECT: "false"},
return_value={UIParameter.NA_ENABLE_REGIONLESS_REDIRECT: False},
)
def test_deploy_with_artifacts_from_other_directory(
mock_param,
Expand Down
29 changes: 0 additions & 29 deletions tests/streamlit/test_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -920,35 +920,6 @@ def test_deploy_streamlit_main_and_pages_files_experimental_replace(
]


@pytest.mark.parametrize(
"project_name,opts",
[
("example_streamlit", {"streamlit": {"pages_dir": "foo.bar"}}),
("example_streamlit", {"streamlit": {"env_file": "foo.bar"}}),
(
"example_streamlit_v2",
{"entities": {"test_streamlit": {"pages_dir": "foo.bar"}}},
),
(
"example_streamlit_v2",
{"entities": {"test_streamlit": {"artifacts": ["foo.bar"]}}},
),
],
)
@mock.patch("snowflake.connector.connect")
def test_deploy_streamlit_nonexisting_file(
mock_connector, runner, mock_ctx, snapshot, project_directory, opts, project_name
):
ctx = mock_ctx()
mock_connector.return_value = ctx

with project_directory(project_name, merge_project_definition=opts):
result = runner.invoke(["streamlit", "deploy"])

assert result.exit_code == 1
assert result.output == snapshot


@mock.patch("snowflake.connector.connect")
def test_share_streamlit(mock_connector, runner, mock_ctx):
ctx = mock_ctx()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import streamlit as st
from common.hello import say_hello

import streamlit as st

st.title(f"Example streamlit app. {say_hello()}")
3 changes: 3 additions & 0 deletions tests/testing_utils/fixtures.py
Original file line number Diff line number Diff line change
Expand Up @@ -473,5 +473,8 @@ def enable_snowpark_glob_support_feature_flag():
with mock.patch(
f"snowflake.cli.api.feature_flags.FeatureFlag.ENABLE_SNOWPARK_GLOB_SUPPORT.is_enabled",
return_value=True,
), mock.patch(
f"snowflake.cli.api.feature_flags.FeatureFlag.ENABLE_SNOWPARK_GLOB_SUPPORT.is_disabled",
return_value=False,
):
yield
3 changes: 3 additions & 0 deletions tests_integration/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -266,5 +266,8 @@ def enable_snowpark_glob_support_feature_flag():
with mock.patch(
f"snowflake.cli.api.feature_flags.FeatureFlag.ENABLE_SNOWPARK_GLOB_SUPPORT.is_enabled",
return_value=True,
), mock.patch(
f"snowflake.cli.api.feature_flags.FeatureFlag.ENABLE_SNOWPARK_GLOB_SUPPORT.is_disabled",
return_value=False,
):
yield

0 comments on commit 1748f3d

Please sign in to comment.