|
1 | 1 | """Functional test for _execute_sql.""" |
2 | 2 |
|
3 | 3 | from typing import Generator |
4 | | -from unittest.mock import MagicMock |
5 | 4 |
|
6 | 5 | import pytest |
7 | 6 | from snowflake.connector import SnowflakeConnection |
8 | 7 |
|
9 | 8 | from ds_platform_utils._snowflake.run_query import _execute_sql |
10 | | -from ds_platform_utils.metaflow.snowflake_connection import _create_snowflake_connection |
| 9 | +from ds_platform_utils.metaflow.snowflake_connection import get_snowflake_connection |
11 | 10 |
|
12 | 11 |
|
13 | 12 | @pytest.fixture(scope="module") |
14 | | -def patched_current() -> Generator[MagicMock, None, None]: |
15 | | - """Patch Metaflow `current` object for modules used in this test file.""" |
16 | | - mock_current = MagicMock("metaflow.current") |
17 | | - mock_current.tags = ["ds.domain:testing", "ds.project:unit-tests"] |
18 | | - mock_current.flow_name = "DummyFlow" |
19 | | - mock_current.project_name = "dummy-project" |
20 | | - mock_current.step_name = "dummy-step" |
21 | | - mock_current.run_id = "123" |
22 | | - mock_current.username = "tester" |
23 | | - mock_current.is_production = False |
24 | | - mock_current.namespace = "user:tester" |
25 | | - mock_current.is_running_flow = True |
26 | | - mock_current.card = [] |
27 | | - yield mock_current |
28 | | - |
29 | | - |
30 | | -@pytest.fixture(scope="module") |
31 | | -def snowflake_conn(patched_current) -> Generator[SnowflakeConnection, None, None]: |
| 13 | +def snowflake_conn() -> Generator[SnowflakeConnection, None, None]: |
32 | 14 | """Get a Snowflake connection for testing.""" |
33 | | - yield _create_snowflake_connection(warehouse=None, use_utc=True) |
| 15 | + from metaflow import current |
| 16 | + |
| 17 | + current.is_production = False # Ensure we're in non-prod for testing |
| 18 | + yield get_snowflake_connection(warehouse=None, use_utc=True) |
34 | 19 |
|
35 | 20 |
|
36 | 21 | def test_execute_sql_empty_string(snowflake_conn): |
|
0 commit comments