Skip to content

Commit

Permalink
Added test
Browse files Browse the repository at this point in the history
  • Loading branch information
sfc-gh-jsikorski committed Sep 18, 2024
1 parent ff5b5bb commit 01f7b02
Show file tree
Hide file tree
Showing 6 changed files with 92 additions and 25 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
from __future__ import annotations
from snowflake.snowpark import Session
from b import test_procedure


# test import
import syrupy


def hello_procedure(session: Session, name: str) -> str:

return f"Hello {name}" + test_procedure(session)
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
from __future__ import annotations
from snowflake.snowpark import Session


# test import
import syrupy


def test_procedure(session: Session) -> str:
return "Test procedure"
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
snowflake-snowpark-pythonsyrupy
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
definition_version: 2

mixins:
snowpark_shared:
stage: "dev_deployment"

entities:
hello_procedure:
type: "procedure"
stage: "stage_a"
identifier:
name: "hello_procedure"
handler: "a.hello_procedure"
signature:
- name: "name"
type: "string"
returns: string
artifacts:
- "app_1/"

test:
type: "procedure"
handler: "b.test_procedure"
signature: ""
returns: string
artifacts:
- "app_2/"
meta:
use_mixins:
- "snowpark_shared"

hello_function:
type: "function"
handler: "c.hello_function"
signature:
- name: "name"
type: "string"
returns: string
artifacts:
- "c.py"
meta:
use_mixins:
- "snowpark_shared"
26 changes: 1 addition & 25 deletions tests_integration/test_data/projects/snowpark_v2/snowflake.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,28 +16,4 @@ entities:
type: "string"
returns: string
artifacts:
- "app_1/"

test:
type: "procedure"
handler: "b.test_procedure"
signature: ""
returns: string
artifacts:
- "app_2/"
meta:
use_mixins:
- "snowpark_shared"

hello_function:
type: "function"
handler: "c.hello_function"
signature:
- name: "name"
type: "string"
returns: string
artifacts:
- "c.py"
meta:
use_mixins:
- "snowpark_shared"
- "app_1/*"
25 changes: 25 additions & 0 deletions tests_integration/test_snowpark.py
Original file line number Diff line number Diff line change
Expand Up @@ -993,6 +993,31 @@ def test_snowpark_flow_v2(
)


@pytest.mark.integration
def test_snowpark_with_glob_patterns(
_test_steps, project_directory, alter_snowflake_yml, test_database
):
database = test_database.upper()
with project_directory("snowpark_glob_patterns") as tmp_dir:
_test_steps.snowpark_build_should_zip_files(
additional_files=[Path("app_1.zip"), Path("app_2.zip")]
)
_test_steps.snowpark_deploy_should_finish_successfully_and_return(
[
{
"object": f"{database}.PUBLIC.hello_procedure(name string)",
"status": "created",
"type": "procedure",
}
]
)
_test_steps.snowpark_execute_should_return_expected_value(
object_type="procedure",
identifier="hello_procedure('foo')",
expected_value="Hello foo" + "Test procedure",
)


@pytest.fixture
def _test_setup(
runner,
Expand Down

0 comments on commit 01f7b02

Please sign in to comment.