Skip to content

Commit

Permalink
add unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
colin-rogers-dbt committed Sep 26, 2023
1 parent 773d96d commit 790f6da
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
2 changes: 1 addition & 1 deletion dbt/adapters/snowflake/connections.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
from dbt.adapters.base import Credentials # type: ignore
from dbt.contracts.connection import AdapterResponse, Connection
from dbt.adapters.sql import SQLConnectionManager # type: ignore
from dbt.common.events import AdapterLogger # type: ignore
from dbt.events import AdapterLogger # type: ignore
from dbt.events.functions import warn_or_error
from dbt.events.types import AdapterEventWarning
from dbt.ui import line_wrap_message, warning_tag
Expand Down
24 changes: 24 additions & 0 deletions tests/unit/test_connections.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import os
from unittest.mock import Mock

import dbt.events


def test_connections_sets_logs_in_response_to_env_var(monkeypatch):
"""Test that setting the DBT_SNOWFLAKE_CONNECTOR_DEBUG_LOGGING environment variable happens on import"""
log_mock = Mock()
monkeypatch.setattr(dbt.events, "AdapterLogger", Mock(return_value=log_mock))
os.environ["DBT_SNOWFLAKE_CONNECTOR_DEBUG_LOGGING"] = "true"
import dbt.adapters.snowflake.connections as connections # noqa

assert log_mock.debug.call_count == 3
assert log_mock.set_adapter_dependency_log_level.call_count == 3


def test_connections_does_not_set_logs_in_response_to_env_var(monkeypatch):
log_mock = Mock()
monkeypatch.setattr(dbt.events, "AdapterLogger", Mock(return_value=log_mock))
import dbt.adapters.snowflake.connections as connections # noqa

assert log_mock.debug.call_count == 0
assert log_mock.set_adapter_dependency_log_level.call_count == 0

0 comments on commit 790f6da

Please sign in to comment.