Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Teradata Profile Issue Fix - Credentials in profile "generated_profile", target "dev" invalid: Runtime Error Must specify schema in Teradata profile #2

Merged
merged 8 commits into from
Jul 10, 2024
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"