From 5f15b399409cd48a084e93624852e7556259811b Mon Sep 17 00:00:00 2001 From: Daniel Wolf Date: Wed, 13 Nov 2024 16:09:58 +0100 Subject: [PATCH 1/3] TrinoBaseProfileMapping: set mock value of port to an integer --- cosmos/profiles/trino/base.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/cosmos/profiles/trino/base.py b/cosmos/profiles/trino/base.py index a3c242d8f9..5554d340e2 100644 --- a/cosmos/profiles/trino/base.py +++ b/cosmos/profiles/trino/base.py @@ -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://", "") From 39e5008f5151a0b3c4a9588f878520fdab6d0912 Mon Sep 17 00:00:00 2001 From: Daniel Wolf Date: Thu, 14 Nov 2024 20:30:25 +0100 Subject: [PATCH 2/3] Add mock_profile test to trino base profile --- tests/profiles/trino/test_trino_base.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/tests/profiles/trino/test_trino_base.py b/tests/profiles/trino/test_trino_base.py index ee03821e2f..a40ce3ddd9 100644 --- a/tests/profiles/trino/test_trino_base.py +++ b/tests/profiles/trino/test_trino_base.py @@ -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" + } From 973b0a13a7bead35f08ba11a73db10f66e9235dd Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Thu, 14 Nov 2024 19:30:54 +0000 Subject: [PATCH 3/3] =?UTF-8?q?=F0=9F=8E=A8=20[pre-commit.ci]=20Auto=20for?= =?UTF-8?q?mat=20from=20pre-commit.com=20hooks?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tests/profiles/trino/test_trino_base.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/profiles/trino/test_trino_base.py b/tests/profiles/trino/test_trino_base.py index a40ce3ddd9..19f78c1ef5 100644 --- a/tests/profiles/trino/test_trino_base.py +++ b/tests/profiles/trino/test_trino_base.py @@ -91,12 +91,12 @@ 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" - } + "user": "mock_value", + }