-
Notifications
You must be signed in to change notification settings - Fork 199
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
Make GoogleCloudServiceAccountDictProfileMapping dataset profile argument optional #839
Closed
oliverrmaa
wants to merge
9
commits into
astronomer:main
from
oliverrmaa:make-gcp-dataset-profile-arg-optional
Closed
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
d5a0c24
first commit
oliverrmaa 87c43da
🎨 [pre-commit.ci] Auto format from pre-commit.com hooks
pre-commit-ci[bot] 386682e
attempt at fixing failing unit tests
oliverrmaa fafdb87
fix wrong reference
oliverrmaa f7cfc1e
fix unit tests
oliverrmaa 130b1cb
added dataset: None in wrong place
oliverrmaa 87d2e72
Merge branch 'main' into make-gcp-dataset-profile-arg-optional
tatiana 0dfcd9d
Merge branch 'main' into make-gcp-dataset-profile-arg-optional
tatiana ef78fe9
Merge branch 'main' into make-gcp-dataset-profile-arg-optional
tatiana File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -64,8 +64,8 @@ def test_connection_claiming_succeeds(mock_bigquery_conn_with_dict: Connection): | |
|
||
|
||
def test_connection_claiming_fails(mock_bigquery_conn_with_dict: Connection): | ||
# Remove the `dataset` key, which is mandatory | ||
mock_bigquery_conn_with_dict.extra = json.dumps({"project": "my_project", "keyfile_dict": sample_keyfile_dict}) | ||
# Remove the `project` key, which is mandatory | ||
mock_bigquery_conn_with_dict.extra = json.dumps({"keyfile_dict": sample_keyfile_dict}) | ||
profile_mapping = GoogleCloudServiceAccountDictProfileMapping(mock_bigquery_conn_with_dict, {}) | ||
assert not profile_mapping.can_claim_connection() | ||
|
||
|
@@ -87,6 +87,33 @@ def test_profile(mock_bigquery_conn_with_dict: Connection): | |
assert profile_mapping.profile == expected | ||
|
||
|
||
def test_profile_without_dataset(mock_bigquery_conn_with_dict: Connection): | ||
mock_bigquery_conn_with_dict.extra = json.dumps( | ||
{ | ||
"project": "my_project", | ||
"keyfile_dict": json.dumps(sample_keyfile_dict), | ||
} | ||
) | ||
|
||
profile_mapping = GoogleCloudServiceAccountDictProfileMapping(mock_bigquery_conn_with_dict, {}) | ||
|
||
# Expected profile does not include 'dataset' | ||
expected = { | ||
"type": "bigquery", | ||
"method": "service-account-json", | ||
"project": "my_project", | ||
"dataset": None, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do you know if having dataset: null
keyfile_json:
private_key: '{{ env_var(''COSMOS_CONN_GOOGLE_CLOUD_PLATFORM_PRIVATE_KEY'') }}'
private_key_id: '{{ env_var(''COSMOS_CONN_GOOGLE_CLOUD_PLATFORM_PRIVATE_KEY_ID'')
}}'
type: service_account
method: service-account-json
project: my_project
threads: 1
type: bigquery Would the |
||
"threads": 1, | ||
"keyfile_json": { | ||
"type": "service_account", | ||
"private_key_id": "{{ env_var('COSMOS_CONN_GOOGLE_CLOUD_PLATFORM_PRIVATE_KEY_ID') }}", | ||
"private_key": "{{ env_var('COSMOS_CONN_GOOGLE_CLOUD_PLATFORM_PRIVATE_KEY') }}", | ||
}, | ||
} | ||
|
||
assert profile_mapping.profile == expected | ||
|
||
|
||
def test_mock_profile(mock_bigquery_conn_with_dict: Connection): | ||
""" | ||
Tests profile mock for keyfile_json is None. Giving keyfile_json a value will crash dbt ls. | ||
|
@@ -96,7 +123,6 @@ def test_mock_profile(mock_bigquery_conn_with_dict: Connection): | |
"type": "bigquery", | ||
"method": "service-account-json", | ||
"project": "mock_value", | ||
"dataset": "mock_value", | ||
"threads": 1, | ||
"keyfile_json": None, | ||
} | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this is needed since if dataset is already in profile_args it will be merged above in: