File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 77LOGGER = get_logger ()
88
99
10- def write_state (state ):
11- json .dump (state .to_dict (), sys .stdout , indent = 2 )
12-
13-
1410class State :
1511 def __init__ (
1612 self , bookmarks : Optional [Dict ] = None , currently_syncing : Optional [str ] = None # pylint: disable=bad-continuation
@@ -28,11 +24,6 @@ def __eq__(self, other: Any) -> bool:
2824 def bookmarks (self ) -> Dict :
2925 return self ._bookmarks
3026
31- @classmethod
32- def load (cls , filename : str ) -> "State" :
33- with open (filename ) as fp : # pylint: disable=invalid-name
34- return State .from_dict (json .load (fp ))
35-
3627 @classmethod
3728 def from_dict (cls , data : Dict ) -> "State" :
3829 return State (
@@ -46,9 +37,6 @@ def to_dict(self) -> Dict:
4637 state ["currently_syncing" ] = self .get_currently_syncing ()
4738 return state
4839
49- def dump (self ) -> None :
50- json .dump (self .to_dict (), sys .stdout , indent = 2 )
51-
5240 def _ensure_bookmark_path (self , path : Sequence ) -> None :
5341 submap = self .bookmarks
5442 for path_component in path :
Original file line number Diff line number Diff line change 11from copy import copy
22import unittest
3- from singer .bookmarks import State , write_state
4-
5-
6- class TestWriteState (unittest .TestCase ):
7- def test_write_empty_state (self ):
8- state = State ()
9- write_state (state )
10-
11- def test_write_state_with_bookmarks (self ):
12- stream_id_1 = "customers"
13- bookmark_key_1 = "datetime"
14- bookmark_val_1 = 123456789
15- offset_key = "key"
16- offset_val = "fizzy water"
17-
18- bookmarks = {
19- stream_id_1 : {
20- bookmark_key_1 : bookmark_val_1 ,
21- "offset" : {offset_key : offset_val },
22- }
23- }
24-
25- state = State (bookmarks = bookmarks , currently_syncing = "customers" )
26- write_state (state )
3+ from singer .bookmarks import State
274
285
296class TestGetBookmark (unittest .TestCase ):
You can’t perform that action at this time.
0 commit comments