Skip to content

Commit

Permalink
Teradata Profile Mapping Issue - Credentials in profile "generated_pr…
Browse files Browse the repository at this point in the history
…ofile", target "dev" invalid: Runtime Error Must specify `schema` in Teradata profile (astronomer#1088)

`TeradataUserPassword` profile mapping throws below error for mock
profile

```
Credentials in profile "generated_profile", target "dev" invalid:
Runtime Error Must specify the schema in Teradata profile
```

Closes astronomer#1087
  • Loading branch information
sc250072 authored and arojasb3 committed Jul 14, 2024
1 parent c5780aa commit 5fa3752
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 5fa3752

Please sign in to comment.