Skip to content

Commit

Permalink
Fix the mock value of port in TrinoBaseProfileMapping to be an inte…
Browse files Browse the repository at this point in the history
…ger (#1322)

The mock value of `port` in `TrinoBaseProfileMapping` has been changed
to an integer.

Closes: #1315
  • Loading branch information
dwolfeu authored Nov 15, 2024
1 parent 9a19084 commit 7d487a0
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
6 changes: 6 additions & 0 deletions cosmos/profiles/trino/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,12 @@ def profile(self) -> dict[str, Any]:
# remove any null values
return self.filter_null(profile_vars)

@property
def mock_profile(self) -> dict[str, Any]:
mock_profile = super().mock_profile
mock_profile["port"] = 99999
return mock_profile

def transform_host(self, host: str) -> str:
"""Replaces http:// or https:// with nothing."""
return host.replace("http://", "").replace("https://", "")
16 changes: 16 additions & 0 deletions tests/profiles/trino/test_trino_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,3 +84,19 @@ def test_profile_args_overrides() -> None:
"user": "my_login",
"session_properties": {"my_property": "my_value_override"},
}


def test_mock_profile() -> None:
"""
Tests that the mock_profile values get set correctly. A non-integer value of port will crash dbt ls.
"""
profile_mapping = TrinoBaseProfileMapping(conn_id="mock_conn_id")

assert profile_mapping.mock_profile == {
"type": "trino",
"host": "mock_value",
"database": "mock_value",
"schema": "mock_value",
"port": 99999,
"user": "mock_value",
}

0 comments on commit 7d487a0

Please sign in to comment.