Skip to content

Commit

Permalink
Teradata Profile Issue Fix - Credentials in profile "generated_profil…
Browse files Browse the repository at this point in the history
…e", target "dev" invalid: Runtime Error Must specify `schema` in Teradata profile

Addressed the issue - Credentials in profile "generated_profile", target "dev" invalid: Runtime Error     Must specify `schema` in Teradata profile (#2)
  • Loading branch information
sc250072 authored Jul 10, 2024
1 parent 3ff8d10 commit 9f54d1e
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
7 changes: 7 additions & 0 deletions cosmos/profiles/teradata/user_pass.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,3 +49,10 @@ def profile(self) -> dict[str, Any]:
profile["schema"] = profile["user"]

return self.filter_null(profile)

@property
def mock_profile(self) -> dict[str, Any | None]:
"""Gets mock profile. Assigning user to schema as default"""
mock_profile = super().mock_profile
mock_profile["schema"] = mock_profile["user"]
return mock_profile
9 changes: 9 additions & 0 deletions tests/profiles/teradata/test_teradata_user_pass.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,12 @@ def test_profile_mapping_selected(
assert isinstance(profile_mapping, TeradataUserPasswordProfileMapping)


def test_profile_mapping_schema_validation(mock_teradata_conn: Connection) -> None:
# port is not handled in airflow connection so adding it as profile_args
profile = TeradataUserPasswordProfileMapping(mock_teradata_conn.conn_id)
assert profile.profile["schema"] == "my_user"


def test_profile_mapping_keeps_port(mock_teradata_conn: Connection) -> None:
# port is not handled in airflow connection so adding it as profile_args
profile = TeradataUserPasswordProfileMapping(mock_teradata_conn.conn_id, profile_args={"port": 1025})
Expand Down Expand Up @@ -174,3 +180,6 @@ def test_mock_profile() -> None:
"""
profile = TeradataUserPasswordProfileMapping("mock_conn_id")
assert profile.mock_profile.get("host") == "mock_value"
assert profile.mock_profile.get("user") == "mock_value"
assert profile.mock_profile.get("password") == "mock_value"
assert profile.mock_profile.get("schema") == "mock_value"

0 comments on commit 9f54d1e

Please sign in to comment.