Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions cosmos/profiles/databricks/oauth.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,14 @@ class DatabricksOauthProfileMapping(BaseProfileMapping):
"http_path": "extra.http_path",
}

@property
def mock_profile(self) -> dict[str, Any | None]:
"""Generates a mock profile."""
return {
**super().mock_profile,
"auth_type": "oauth",
}

@property
def profile(self) -> dict[str, Any | None]:
"""Generates profile. The client-id and client-secret is stored in an environment variable."""
Expand Down
8 changes: 8 additions & 0 deletions tests/profiles/databricks/test_dbr_oauth.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,3 +69,11 @@ def test_connection_claiming() -> None:
with patch("cosmos.profiles.base.BaseHook.get_connection", return_value=conn):
profile_mapping = DatabricksOauthProfileMapping(conn, {"schema": "my_schema"})
assert profile_mapping.can_claim_connection()


def test_mock_profile() -> None:
"""
Tests that the Databricks mock profile is generated correctly.
"""
profile_mapping = DatabricksOauthProfileMapping("conn_id", {"schema": "my_schema"})
assert profile_mapping.mock_profile.get("auth_type") == "oauth"