Skip to content

Commit

Permalink
additional test updates
Browse files Browse the repository at this point in the history
  • Loading branch information
sfc-gh-jhilgart committed Apr 8, 2024
1 parent 7f7bd1a commit fe5e879
Showing 1 changed file with 22 additions and 2 deletions.
24 changes: 22 additions & 2 deletions semantic_model_generator/tests/snowflake_connector_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,26 @@

from semantic_model_generator.data_processing.data_types import Column, Table
from semantic_model_generator.snowflake_utils import snowflake_connector
from unittest.mock import patch

@pytest.fixture
def mock_snowflake_connection_env(monkeypatch):
# Mock environment variable
monkeypatch.setenv("SNOWFLAKE_HOST", "test_host")

# Use this fixture to also patch instance methods if needed
with patch.object(
snowflake_connector.SnowflakeConnector, "_get_user", return_value="test_user"
), patch.object(
snowflake_connector.SnowflakeConnector, "_get_password", return_value="test_password"
), patch.object(
snowflake_connector.SnowflakeConnector, "_get_role", return_value="test_role"
), patch.object(
snowflake_connector.SnowflakeConnector, "_get_warehouse", return_value="test_warehouse"
), patch.object(
snowflake_connector.SnowflakeConnector, "_get_host", return_value="test_host"
):
yield


@pytest.fixture
Expand Down Expand Up @@ -79,7 +99,7 @@ def valid_tables() -> pd.DataFrame:
@mock.patch(
"semantic_model_generator.snowflake_utils.snowflake_connector.snowflake_connection"
)
def test_connect(mock_snowflake_connection: mock.MagicMock):
def test_connect(mock_snowflake_connection: mock.MagicMock, mock_snowflake_connection_env):
mock_snowflake_connection.return_value = mock.MagicMock()

connector = snowflake_connector.SnowflakeConnector(account_name="test_account")
Expand All @@ -99,7 +119,7 @@ def test_connect(mock_snowflake_connection: mock.MagicMock):
@mock.patch(
"semantic_model_generator.snowflake_utils.snowflake_connector.snowflake_connection"
)
def test_connect_with_schema(mock_snowflake_connection: mock.MagicMock):
def test_connect_with_schema(mock_snowflake_connection: mock.MagicMock, mock_snowflake_connection_env):
mock_snowflake_connection.return_value = mock.MagicMock()

connector = snowflake_connector.SnowflakeConnector(
Expand Down

0 comments on commit fe5e879

Please sign in to comment.