-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3 from Matatika/fix/fix-dynamic-sheet-discovery
Fix/fix dynamic sheet discovery
- Loading branch information
Showing
10 changed files
with
249 additions
and
58 deletions.
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 |
---|---|---|
|
@@ -3,25 +3,35 @@ send_anonymous_usage_stats: true | |
project_id: 04da77a3-af12-49a4-b9bf-3c22845918ba | ||
plugins: | ||
extractors: | ||
- name: tap-google-sheets | ||
namespace: tap_google_sheets | ||
pip_url: -e . | ||
capabilities: | ||
- state | ||
- catalog | ||
- discover | ||
settings: | ||
- name: oauth_credentials.client_id | ||
kind: password | ||
- name: oauth_credentials.client_secret | ||
kind: password | ||
- name: oauth_credentials.refresh_token | ||
kind: password | ||
- name: sheet_id | ||
- name: tap-google-sheets | ||
namespace: tap_google_sheets | ||
pip_url: -e . | ||
capabilities: | ||
- state | ||
- catalog | ||
- discover | ||
select: | ||
- spreadsheet.* | ||
settings: | ||
- name: oauth_credentials.client_id | ||
kind: password | ||
- name: oauth_credentials.client_secret | ||
kind: password | ||
- name: oauth_credentials.refresh_token | ||
kind: password | ||
- name: sheet_id | ||
- name: stream_name | ||
- name: child_sheet_name | ||
loaders: | ||
- name: target-jsonl | ||
variant: andyh1203 | ||
pip_url: target-jsonl | ||
- name: target-postgres | ||
variant: transferwise | ||
pip_url: pipelinewise-target-postgres | ||
- name: target-jsonl | ||
variant: andyh1203 | ||
pip_url: target-jsonl | ||
- name: target-postgres | ||
variant: transferwise | ||
pip_url: pipelinewise-target-postgres | ||
- name: target-csv | ||
variant: hotgluexyz | ||
pip_url: git+https://github.com/hotgluexyz/[email protected] | ||
- name: target-snowflake | ||
variant: meltano | ||
pip_url: git+https://github.com/Matatika/[email protected] |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
"""Tests tap setting child_sheet_name.""" | ||
|
||
import unittest | ||
|
||
import responses | ||
import singer | ||
|
||
import tap_google_sheets.tests.utils as test_utils | ||
from tap_google_sheets.tap import TapGoogleSheets | ||
|
||
|
||
class TestChildSheetNameSetting(unittest.TestCase): | ||
"""Test class for tap setting child_sheet_name""" | ||
|
||
def setUp(self): | ||
self.mock_config = { | ||
"oauth_credentials": { | ||
"client_id": "123", | ||
"client_secret": "123", | ||
"refresh_token": "123", | ||
}, | ||
"sheet_id": "12345", | ||
} | ||
self.mock_config["child_sheet_name"] = "Test Sheet" | ||
|
||
responses.reset() | ||
del test_utils.SINGER_MESSAGES[:] | ||
|
||
singer.write_message = test_utils.accumulate_singer_messages | ||
|
||
@responses.activate() | ||
def test_discovered_stream_name(self): | ||
"""""" | ||
self.column_response = {"values": [["Column One", "Column Two"], ["1", "1"]]} | ||
|
||
responses.add( | ||
responses.POST, | ||
"https://oauth2.googleapis.com/token", | ||
json={"access_token": "new_token"}, | ||
status=200, | ||
), | ||
responses.add( | ||
responses.GET, | ||
"https://www.googleapis.com/drive/v2/files/12345", | ||
json={"title": "File Name One"}, | ||
status=200, | ||
), | ||
responses.add( | ||
responses.GET, | ||
"https://sheets.googleapis.com/v4/spreadsheets/12345/values/" | ||
+ "Test%20Sheet!1:1", | ||
json={ | ||
"range": "Test%20Sheet!1:1", | ||
"values": [["Column One", "Column Two"]], | ||
}, | ||
status=200, | ||
), | ||
responses.add( | ||
responses.GET, | ||
"https://sheets.googleapis.com/v4/spreadsheets/12345/values/Test%20Sheet", | ||
json=self.column_response, | ||
status=200, | ||
) | ||
|
||
tap = TapGoogleSheets(config=self.mock_config) | ||
|
||
tap.sync_all() | ||
|
||
self.assertEqual(len(test_utils.SINGER_MESSAGES), 4) | ||
self.assertIsInstance(test_utils.SINGER_MESSAGES[0], singer.SchemaMessage) | ||
self.assertIsInstance(test_utils.SINGER_MESSAGES[1], singer.SchemaMessage) | ||
self.assertIsInstance(test_utils.SINGER_MESSAGES[2], singer.RecordMessage) | ||
self.assertIsInstance(test_utils.SINGER_MESSAGES[3], singer.StateMessage) | ||
|
||
# Assert that data is sycned from the mocked response | ||
self.assertEquals( | ||
test_utils.SINGER_MESSAGES[2].record, {"Column_One": "1", "Column_Two": "1"} | ||
) |
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
Oops, something went wrong.