Skip to content

Commit

Permalink
feat: Update singer-sdk to latest compatible version (#20)
Browse files Browse the repository at this point in the history
* Update `singer-sdk` to latest compatible version

* Fix import order

* Remove redundant type hints
  • Loading branch information
ReubenFrankel authored Mar 20, 2024
1 parent 9fdc747 commit c4a8d22
Show file tree
Hide file tree
Showing 8 changed files with 99 additions and 45 deletions.
81 changes: 65 additions & 16 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ license = "GNU Affero General Public License v3.0"
[tool.poetry.dependencies]
python = "<3.13,>=3.7.1"
requests = "^2.31.0"
singer-sdk = "^0.33.0"
singer-sdk = "^0.34.1"
click = "8.0.1"

[tool.poetry.dev-dependencies]
Expand Down
9 changes: 4 additions & 5 deletions tap_google_sheets/auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import json
from datetime import datetime
from typing import Optional

import requests
from singer_sdk.authenticators import OAuthAuthenticator, SingletonMeta
Expand Down Expand Up @@ -44,10 +43,10 @@ def __init__(
self._auth_body = auth_body

# Initialize internal tracking attributes
self.access_token: Optional[str] = None
self.refresh_token: Optional[str] = None
self.last_refreshed: Optional[datetime] = None
self.expires_in: Optional[int] = None
self.access_token = None
self.refresh_token = None
self.last_refreshed = None
self.expires_in = None

def is_token_valid(self) -> bool:
"""Check if token is valid."""
Expand Down
14 changes: 8 additions & 6 deletions tap_google_sheets/tests/test_child_sheet_name_setting.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

import responses
import singer_sdk._singerlib as singer
import singer_sdk.io_base as io

import tap_google_sheets.tests.utils as test_utils
from tap_google_sheets.tap import TapGoogleSheets
Expand All @@ -26,7 +27,7 @@ def setUp(self):
responses.reset()
del test_utils.SINGER_MESSAGES[:]

singer.write_message = test_utils.accumulate_singer_messages
io.singer_write_message = test_utils.accumulate_singer_messages

@responses.activate()
def test_discovered_stream_name(self):
Expand Down Expand Up @@ -66,13 +67,14 @@ def test_discovered_stream_name(self):

tap.sync_all()

self.assertEqual(len(test_utils.SINGER_MESSAGES), 4)
self.assertIsInstance(test_utils.SINGER_MESSAGES[0], singer.SchemaMessage)
self.assertEqual(len(test_utils.SINGER_MESSAGES), 5)
self.assertIsInstance(test_utils.SINGER_MESSAGES[0], singer.StateMessage)
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)
self.assertIsInstance(test_utils.SINGER_MESSAGES[2], singer.SchemaMessage)
self.assertIsInstance(test_utils.SINGER_MESSAGES[3], singer.RecordMessage)
self.assertIsInstance(test_utils.SINGER_MESSAGES[4], 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"}
test_utils.SINGER_MESSAGES[3].record, {"Column_One": "1", "Column_Two": "1"}
)
4 changes: 2 additions & 2 deletions tap_google_sheets/tests/test_discovered_stream_name.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import unittest

import responses
import singer_sdk._singerlib as singer
import singer_sdk.io_base as io

import tap_google_sheets.tests.utils as test_utils
from tap_google_sheets.tap import TapGoogleSheets
Expand All @@ -18,7 +18,7 @@ def setUp(self):
responses.reset()
del test_utils.SINGER_MESSAGES[:]

singer.write_message = test_utils.accumulate_singer_messages
io.singer_write_message = test_utils.accumulate_singer_messages

@responses.activate()
def test_discovered_stream_name(self):
Expand Down
16 changes: 9 additions & 7 deletions tap_google_sheets/tests/test_ignoring_unnamed_columns.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

import responses
import singer_sdk._singerlib as singer
import singer_sdk.io_base as io

import tap_google_sheets.tests.utils as test_utils
from tap_google_sheets.tap import TapGoogleSheets
Expand All @@ -18,7 +19,7 @@ def setUp(self):
responses.reset()
del test_utils.SINGER_MESSAGES[:]

singer.write_message = test_utils.accumulate_singer_messages
io.singer_write_message = test_utils.accumulate_singer_messages

@responses.activate()
def test_ignoring_unnamed_columns(self):
Expand Down Expand Up @@ -59,18 +60,19 @@ def test_ignoring_unnamed_columns(self):

tap.sync_all()

self.assertEqual(len(test_utils.SINGER_MESSAGES), 5)
self.assertIsInstance(test_utils.SINGER_MESSAGES[0], singer.SchemaMessage)
self.assertEqual(len(test_utils.SINGER_MESSAGES), 6)
self.assertIsInstance(test_utils.SINGER_MESSAGES[0], singer.StateMessage)
self.assertIsInstance(test_utils.SINGER_MESSAGES[1], singer.SchemaMessage)
self.assertIsInstance(test_utils.SINGER_MESSAGES[2], singer.RecordMessage)
self.assertIsInstance(test_utils.SINGER_MESSAGES[2], singer.SchemaMessage)
self.assertIsInstance(test_utils.SINGER_MESSAGES[3], singer.RecordMessage)
self.assertIsInstance(test_utils.SINGER_MESSAGES[4], singer.StateMessage)
self.assertIsInstance(test_utils.SINGER_MESSAGES[4], singer.RecordMessage)
self.assertIsInstance(test_utils.SINGER_MESSAGES[5], singer.StateMessage)

# Assert that the second unnamed column and its values are ignored
self.assertEquals(
test_utils.SINGER_MESSAGES[2].record, {"Column_One": "1", "Column_Two": "1"}
test_utils.SINGER_MESSAGES[3].record, {"Column_One": "1", "Column_Two": "1"}
)

self.assertEquals(
test_utils.SINGER_MESSAGES[3].record, {"Column_One": "2", "Column_Two": "2"}
test_utils.SINGER_MESSAGES[4].record, {"Column_One": "2", "Column_Two": "2"}
)
4 changes: 2 additions & 2 deletions tap_google_sheets/tests/test_table_name_setting.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import unittest

import responses
import singer_sdk._singerlib as singer
import singer_sdk.io_base as io

import tap_google_sheets.tests.utils as test_utils
from tap_google_sheets.tap import TapGoogleSheets
Expand All @@ -19,7 +19,7 @@ def setUp(self):
responses.reset()
del test_utils.SINGER_MESSAGES[:]

singer.write_message = test_utils.accumulate_singer_messages
io.singer_write_message = test_utils.accumulate_singer_messages

@responses.activate()
def test_output_name(self):
Expand Down
14 changes: 8 additions & 6 deletions tap_google_sheets/tests/test_underscoring_column_names.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

import responses
import singer_sdk._singerlib as singer
import singer_sdk.io_base as io

import tap_google_sheets.tests.utils as test_utils
from tap_google_sheets.tap import TapGoogleSheets
Expand All @@ -18,7 +19,7 @@ def setUp(self):
responses.reset()
del test_utils.SINGER_MESSAGES[:]

singer.write_message = test_utils.accumulate_singer_messages
io.singer_write_message = test_utils.accumulate_singer_messages

@responses.activate()
def test_underscoring_column_names(self):
Expand Down Expand Up @@ -67,15 +68,16 @@ def test_underscoring_column_names(self):

tap.sync_all()

self.assertEqual(len(test_utils.SINGER_MESSAGES), 4)
self.assertIsInstance(test_utils.SINGER_MESSAGES[0], singer.SchemaMessage)
self.assertEqual(len(test_utils.SINGER_MESSAGES), 5)
self.assertIsInstance(test_utils.SINGER_MESSAGES[0], singer.StateMessage)
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)
self.assertIsInstance(test_utils.SINGER_MESSAGES[2], singer.SchemaMessage)
self.assertIsInstance(test_utils.SINGER_MESSAGES[3], singer.RecordMessage)
self.assertIsInstance(test_utils.SINGER_MESSAGES[4], singer.StateMessage)

# Assert that column names have been underscored
self.assertEquals(
test_utils.SINGER_MESSAGES[2].record,
test_utils.SINGER_MESSAGES[3].record,
{
"Column_One": "1",
"Column_Two": "1",
Expand Down

0 comments on commit c4a8d22

Please sign in to comment.