-
Notifications
You must be signed in to change notification settings - Fork 3.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Source Google Sheets: handle config errors (#26097)
* Source Google Sheets: handle config errors * Source Google Sheets: update docs * Source Google Sheets: fix test * Source Google Sheets: add unit tests * auto-bump connector version * Automated Change --------- Co-authored-by: Octavia Squidington III <octavia-squidington-iii@users.noreply.github.com> Co-authored-by: artem1205 <artem1205@users.noreply.github.com>
- Loading branch information
1 parent
1d856ab
commit 0eefa33
Showing
8 changed files
with
70 additions
and
17 deletions.
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