Skip to content

Commit

Permalink
Remove more unnecessary methods
Browse files Browse the repository at this point in the history
  • Loading branch information
judahrand committed Jan 19, 2020
1 parent 73f70b2 commit 6a5a659
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 38 deletions.
14 changes: 0 additions & 14 deletions singer/bookmarks.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,10 @@
import json
import sys
from typing import Any, Dict, Optional, Sequence, Union
from .logger import get_logger


LOGGER = get_logger()


def write_state(state):
json.dump(state.to_dict(), sys.stdout, indent=2)


class State:
def __init__(
self, bookmarks: Optional[Dict] = None, currently_syncing: Optional[str] = None # pylint: disable=bad-continuation
Expand All @@ -28,11 +22,6 @@ def __eq__(self, other: Any) -> bool:
def bookmarks(self) -> Dict:
return self._bookmarks

@classmethod
def load(cls, filename: str) -> "State":
with open(filename) as fp: # pylint: disable=invalid-name
return State.from_dict(json.load(fp))

@classmethod
def from_dict(cls, data: Dict) -> "State":
return State(
Expand All @@ -46,9 +35,6 @@ def to_dict(self) -> Dict:
state["currently_syncing"] = self.get_currently_syncing()
return state

def dump(self) -> None:
json.dump(self.to_dict(), sys.stdout, indent=2)

def _ensure_bookmark_path(self, path: Sequence) -> None:
submap = self.bookmarks
for path_component in path:
Expand Down
25 changes: 1 addition & 24 deletions tests/test_bookmarks.py
Original file line number Diff line number Diff line change
@@ -1,29 +1,6 @@
from copy import copy
import unittest
from singer.bookmarks import State, write_state


class TestWriteState(unittest.TestCase):
def test_write_empty_state(self):
state = State()
write_state(state)

def test_write_state_with_bookmarks(self):
stream_id_1 = "customers"
bookmark_key_1 = "datetime"
bookmark_val_1 = 123456789
offset_key = "key"
offset_val = "fizzy water"

bookmarks = {
stream_id_1: {
bookmark_key_1: bookmark_val_1,
"offset": {offset_key: offset_val},
}
}

state = State(bookmarks=bookmarks, currently_syncing="customers")
write_state(state)
from singer.bookmarks import State


class TestGetBookmark(unittest.TestCase):
Expand Down

0 comments on commit 6a5a659

Please sign in to comment.