-
Notifications
You must be signed in to change notification settings - Fork 3.8k
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
Source Google Sheets: handle config errors #26097
Merged
artem1205
merged 9 commits into
master
from
artem1205/source-google-sheets-config-errors-25691
May 16, 2023
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
c10b145
Source Google Sheets: handle config errors
artem1205 aba725d
Source Google Sheets: update docs
artem1205 d7f35a8
Source Google Sheets: fix test
artem1205 431fd04
Source Google Sheets: add unit tests
artem1205 46d67f2
auto-bump connector version
octavia-squidington-iii 490f9f6
Merge branch 'master' into artem1205/source-google-sheets-config-erro…
artem1205 848c119
Automated Change
artem1205 29f1fa0
Empty-Commit
artem1205 76fbb98
Empty-Commit
artem1205 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
2 changes: 1 addition & 1 deletion
2
airbyte-config-oss/init-oss/src/main/resources/seed/oss_registry.json
Large diffs are not rendered by default.
Oops, something went wrong.
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
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
19 changes: 19 additions & 0 deletions
19
airbyte-integrations/connectors/source-google-sheets/unit_tests/conftest.py
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 |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# | ||
# Copyright (c) 2023 Airbyte, Inc., all rights reserved. | ||
# | ||
|
||
import pytest | ||
|
||
|
||
@pytest.fixture | ||
def invalid_config(): | ||
return { | ||
"spreadsheet_id": "invalid_spreadsheet_id", | ||
"credentials": | ||
{ | ||
"auth_type": "Client", | ||
"client_id": "fake_client_id", | ||
"client_secret": "fake_client_secret", | ||
"refresh_token": "fake_refresh_token" | ||
} | ||
} |
30 changes: 30 additions & 0 deletions
30
airbyte-integrations/connectors/source-google-sheets/unit_tests/test_stream.py
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 |
---|---|---|
@@ -0,0 +1,30 @@ | ||
# | ||
# Copyright (c) 2023 Airbyte, Inc., all rights reserved. | ||
# | ||
|
||
import pytest | ||
import requests | ||
from airbyte_cdk.utils import AirbyteTracedException | ||
from apiclient import errors | ||
from source_google_sheets import SourceGoogleSheets | ||
from source_google_sheets.client import GoogleSheetsClient | ||
from source_google_sheets.helpers import SCOPES | ||
|
||
|
||
def test_invalid_credentials_error_message(invalid_config): | ||
source = SourceGoogleSheets() | ||
with pytest.raises(AirbyteTracedException) as e: | ||
source.check(logger=None, config=invalid_config) | ||
assert e.value.args[0] == 'Access to the spreadsheet expired or was revoked. Re-authenticate to restore access.' | ||
|
||
|
||
def test_invalid_link_error_message(mocker, invalid_config): | ||
source = SourceGoogleSheets() | ||
resp = requests.Response() | ||
resp.status = 404 | ||
mocker.patch.object(GoogleSheetsClient, "__init__", lambda s, credentials, scopes=SCOPES: None) | ||
mocker.patch.object(GoogleSheetsClient, "get", side_effect=errors.HttpError(resp=resp, content=b'')) | ||
with pytest.raises(AirbyteTracedException) as e: | ||
source.check(logger=None, config=invalid_config) | ||
expected_message = 'Config error: The spreadsheet link is not valid. Enter the URL of the Google spreadsheet you want to sync.' | ||
assert e.value.args[0] == expected_message |
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
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.
Can we add unit tests.
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.
tests added