Skip to content

Commit

Permalink
SNOW-1063738 Change tox -e local to run against all integ, unit and m…
Browse files Browse the repository at this point in the history
…ock tests (#1561)

<!---
Please answer these questions before creating your pull request. Thanks!
--->

1. Which Jira issue is this PR addressing? Make sure that there is an
accompanying issue to your PR.

   <!---
   In this section, please add a Snowflake Jira issue number.
   
Note that if a corresponding GitHub issue exists, you should still
include
   the Snowflake Jira issue number. For example, for GitHub issue
#1400, you should
   add "SNOW-1335071" here.
    --->

   Fixes SNOW-1063738

2. Fill out the following pre-review checklist:

- [x] I am adding a new automated test(s) to verify correctness of my
new code
   - [ ] I am adding new logging messages
   - [ ] I am adding a new telemetry message
   - [ ] I am adding new credentials
   - [ ] I am adding a new dependency

3. Please describe how your code solves the related issue.

This PR changes `tox -e local` to run all tests in `tests/integ`,
`tests/unit` and `tests/mock` (previously mock_unit) against Local
Testing (except for modin tests specified in
`SNOWFLAKE_PYTEST_IGNORE_MODIN_CMD`).
  • Loading branch information
sfc-gh-stan authored May 10, 2024
1 parent a9dcf50 commit 935f011
Show file tree
Hide file tree
Showing 21 changed files with 43 additions and 4 deletions.
2 changes: 1 addition & 1 deletion tests/integ/scala/test_dataframe_writer_suite.py
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ def test_write_with_target_column_name_order_all_kinds_of_dataframes(
Utils.drop_stage(session, target_stage_name)


@pytest.mark.skipfi(
@pytest.mark.skipif(
"config.getvalue('local_testing_mode')",
reason="FEAT: session._table_exists not supported",
)
Expand Down
18 changes: 18 additions & 0 deletions tests/integ/scala/test_session_suite.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,11 @@
from tests.utils import IS_IN_STORED_PROC, IS_IN_STORED_PROC_LOCALFS, Utils


@pytest.mark.xfail(
"config.getvalue('local_testing_mode')",
reason="This is testing logging into Snowflake",
run=False,
)
@pytest.mark.skipif(
IS_IN_STORED_PROC, reason="creating new session is not allowed in stored proc"
)
Expand Down Expand Up @@ -123,6 +128,11 @@ def test_get_schema_database_works_after_use_role(session):
session.use_role(current_role)


@pytest.mark.xfail(
"config.getvalue('local_testing_mode')",
reason="_remove_config is an internal API and local testing has default schema name",
run=False,
)
@pytest.mark.skipif(
IS_IN_STORED_PROC, reason="creating new session is not allowed in stored proc"
)
Expand Down Expand Up @@ -190,6 +200,10 @@ def test_create_dataframe_from_array(session, local_testing_mode):
assert "Unsupported datatype" in str(ex_info)


@pytest.mark.skipif(
"config.getvalue('local_testing_mode')",
reason="SNOW-1375271: match error behavior when session is closed",
)
@pytest.mark.skipif(
IS_IN_STORED_PROC, reason="creating new session is not allowed in stored proc"
)
Expand Down Expand Up @@ -231,6 +245,10 @@ def test_session_info(session):
assert "python.connector.version" in session_info


@pytest.mark.skipif(
"config.getvalue('local_testing_mode')",
reason="SNOW-1375271: match error behavior when session is closed",
)
@pytest.mark.skipif(
IS_IN_STORED_PROC, reason="creating new session is not allowed in stored proc"
)
Expand Down
4 changes: 4 additions & 0 deletions tests/integ/test_df_analytics.py
Original file line number Diff line number Diff line change
Expand Up @@ -444,6 +444,10 @@ def test_lead_lag_invalid_inputs(session):
assert "lags must be a list of integers > 0" in str(exc)


@pytest.mark.skipif(
"config.getvalue('local_testing_mode')",
reason="SNOW-1375417: bug in calculate_type raises TypeError for Long division",
)
@pytest.mark.skipif(not is_pandas_available, reason="pandas is required")
def test_time_series_agg(session):
"""Tests time_series_agg_fixed function with various window sizes."""
Expand Down
10 changes: 10 additions & 0 deletions tests/integ/test_lineage.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
# Copyright (c) 2012-2024 Snowflake Computing Inc. All rights reserved.
#


import json
import uuid

Expand All @@ -19,6 +20,15 @@
is_pandas_available = False


pytestmark = [
pytest.mark.xfail(
"config.getvalue('local_testing_mode')",
reason="Lineage is a SQL feature",
run=False,
)
]


def create_objects_for_test(session, db, schema) -> None:
# Create table and views within the specified TESTDB and TESTSCHEMA
session.sql(f"CREATE OR REPLACE TABLE {db}.{schema}.T1(C1 INT)").collect()
Expand Down
7 changes: 5 additions & 2 deletions tests/integ/test_session.py
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,9 @@ def test_create_session_from_parameters(

@pytest.mark.localtest
@pytest.mark.skipif(IS_IN_STORED_PROC, reason="Cannot create session in SP")
def test_create_session_from_connection(db_parameters, sql_simplifier_enabled):
def test_create_session_from_connection(
db_parameters, sql_simplifier_enabled, local_testing_mode
):
connection = snowflake.connector.connect(**db_parameters)
session_builder = Session.builder.configs({"connection": connection})
new_session = session_builder.create()
Expand All @@ -346,7 +348,8 @@ def test_create_session_from_connection(db_parameters, sql_simplifier_enabled):
df = new_session.createDataFrame([[1, 2]], schema=["a", "b"])
Utils.check_answer(df, [Row(1, 2)])
assert session_builder._options.get("password") is None
assert new_session._conn._lower_case_parameters.get("password") is None
if not local_testing_mode:
assert new_session._conn._lower_case_parameters.get("password") is None
assert new_session._conn._conn._password is None
finally:
new_session.close()
Expand Down
4 changes: 4 additions & 0 deletions tests/integ/test_stored_procedure.py
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,10 @@ def test_call_named_stored_procedure(
# restore active session


@pytest.mark.skipif(
"config.getvalue('local_testing_mode')",
reason="Structured types are not supported in Local Testing",
)
@pytest.mark.skipif(
not IS_STRUCTURED_TYPES_SUPPORTED,
reason="Structured types not enabled in this account.",
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ commands =
udf: {env:SNOWFLAKE_PYTEST_CMD} -m "{env:SNOWFLAKE_TEST_TYPE} or udf" {posargs:} src/snowflake/snowpark tests
notdoctest: {env:SNOWFLAKE_PYTEST_CMD} -m "{env:SNOWFLAKE_TEST_TYPE} or udf" {posargs:} tests
notudfdoctest: {env:SNOWFLAKE_PYTEST_CMD} -m "{env:SNOWFLAKE_TEST_TYPE} and not udf" {posargs:} tests
local: {env:SNOWFLAKE_PYTEST_CMD} --local_testing_mode -m "(integ and localtest) or unit or mock_unit" {posargs:} tests
local: {env:SNOWFLAKE_PYTEST_CMD} --local_testing_mode -m "integ or unit or mock" {posargs:} tests
dailynotdoctest: {env:SNOWFLAKE_PYTEST_DAILY_CMD} -m "{env:SNOWFLAKE_TEST_TYPE} or udf" {posargs:} tests
# Snowpark pandas commands:
snowparkpandasnotdoctest: {env:MODIN_PYTEST_CMD} --durations=20 -m "{env:SNOWFLAKE_TEST_TYPE}" {posargs:} {env:SNOW_1314507_WORKAROUND_RERUN_FLAGS} tests/unit/modin tests/integ/modin
Expand Down

0 comments on commit 935f011

Please sign in to comment.