Skip to content

Commit

Permalink
docs: Add doctest for get_starting_timestamp
Browse files Browse the repository at this point in the history
  • Loading branch information
edgarrmondragon committed Jan 19, 2024
1 parent 634a2cc commit bc70d11
Showing 1 changed file with 42 additions and 0 deletions.
42 changes: 42 additions & 0 deletions singer_sdk/streams/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,48 @@ def get_starting_timestamp(self, context: dict | None) -> datetime.datetime | No
Raises:
ValueError: If the replication value is not a valid timestamp.
>>> from singer_sdk import Tap
>>> class MyStream(Stream):
>>> name = "my_stream"
>>> replication_key = "updated_at"
... def get_records(self, context):
... return [{'id': 1, 'updated_at': '2023-01-01T00:00:00Z'}]
>>> class MyTap(Tap):
... name = "my_tap"
...
... def discover_streams(self):
... return [
... MyStream(
... tap=self,
... schema={
... "properties": {
... "id": {"type": "integer"},
... "updated_at": {
... "type": "string",
... "format": "date-time",
... },
... }
... },
... )
... ]
>>> tap = MyTap(
... config={},
... state={
... "bookmarks": {
... "my_stream": {
... "partitions": [],
... "replication_key": "updated_at",
... "replication_key_value": "2020-01-01T00:00:00Z",
... }
... }
... },
... )
>>> tap.streams["my_stream"].is_timestamp_replication_key
True
>>> tap.streams["my_stream"]._write_starting_replication_value(None)
>>> tap.streams["my_stream"].get_starting_timestamp(None)
DateTime(2020, 1, 1, 0, 0, 0, tzinfo=Timezone('UTC'))
"""
value = self.get_starting_replication_key_value(context)

Expand Down

0 comments on commit bc70d11

Please sign in to comment.