Skip to content

Commit

Permalink
[ airbytehq/connector-contest#91 ] Remove uneeded incremental class a…
Browse files Browse the repository at this point in the history
…nd tests, updated doc
  • Loading branch information
andresbravog authored and YiyangLi committed Oct 29, 2022
1 parent bfd6de4 commit a97164f
Show file tree
Hide file tree
Showing 6 changed files with 2 additions and 97 deletions.

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -62,21 +62,6 @@ def parse_response(
) -> Iterable[Mapping]:
return response.json()["entries"]



# Basic incremental stream
class IncrementalPublicApisStream(PublicApisStream, ABC):
state_checkpoint_interval = None

@property
def cursor_field(self) -> str:
return []

def get_updated_state(self, current_stream_state: MutableMapping[str, Any], latest_record: Mapping[str, Any]) -> Mapping[str, Any]:
return {}



# Source
class SourcePublicApis(AbstractSource):
def check_connection(self, logger, config) -> Tuple[bool, any]:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
documentationUrl: https://docsurl.com
documentationUrl: https://api.publicapis.org
connectionSpecification:
$schema: http://json-schema.org/draft-07/schema#
title: Public Apis Spec
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,53 +5,5 @@

from airbyte_cdk.models import SyncMode
from pytest import fixture
from source_public_apis.source import IncrementalPublicApisStream


@fixture
def patch_incremental_base_class(mocker):
# Mock abstract methods to enable instantiating abstract class
mocker.patch.object(IncrementalPublicApisStream, "path", "v0/example_endpoint")
mocker.patch.object(IncrementalPublicApisStream, "primary_key", "test_primary_key")
mocker.patch.object(IncrementalPublicApisStream, "__abstractmethods__", set())


# NOTE: This source does not support incremental updates
def test_cursor_field(patch_incremental_base_class):
stream = IncrementalPublicApisStream()
expected_cursor_field = []
assert stream.cursor_field == expected_cursor_field

# NOTE: This source does not support incremental updates
def test_get_updated_state(patch_incremental_base_class):
stream = IncrementalPublicApisStream()
inputs = {"current_stream_state": None, "latest_record": None}
expected_state = {}
assert stream.get_updated_state(**inputs) == expected_state

# NOTE: This source does not support incremental updates
def test_stream_slices(patch_incremental_base_class):
stream = IncrementalPublicApisStream()
# TODO: replace this with your input parameters
inputs = {"sync_mode": SyncMode.incremental, "cursor_field": [], "stream_state": {}}
# TODO: replace this with your expected stream slices list
expected_stream_slice = [None]
assert stream.stream_slices(**inputs) == expected_stream_slice

# NOTE: This source does not support incremental updates
def test_supports_incremental(patch_incremental_base_class, mocker):
mocker.patch.object(IncrementalPublicApisStream, "cursor_field", "dummy_field")
stream = IncrementalPublicApisStream()
assert stream.supports_incremental

# NOTE: This source does not support incremental updates
def test_source_defined_cursor(patch_incremental_base_class):
stream = IncrementalPublicApisStream()
assert stream.source_defined_cursor

# NOTE: This source does not support incremental updates
def test_stream_checkpoint_interval(patch_incremental_base_class):
stream = IncrementalPublicApisStream()
# TODO: replace this with your expected checkpoint interval
expected_checkpoint_interval = None
assert stream.state_checkpoint_interval == expected_checkpoint_interval
# NOTE: This source does not support incremental updates

0 comments on commit a97164f

Please sign in to comment.