Ejemplo n.º 1
0
def test_get_updated_state_uses_timestamp_of_latest_record_when_no_current_state_exists(patch_incremental_base_class):
    stream = IncrementalPaystackStream(start_date=START_DATE)
    inputs = {"current_stream_state": {}, "latest_record": {stream.cursor_field: "2021-08-02T00:00:00Z"}}

    updated_state = stream.get_updated_state(**inputs)

    assert updated_state == {stream.cursor_field: "2021-08-02T00:00:00Z"}
Ejemplo n.º 2
0
def test_request_params_incremental_start_point_defaults_to_start_date(patch_incremental_base_class):
    stream = IncrementalPaystackStream(start_date=START_DATE)
    inputs = {"stream_slice": None, "next_page_token": None, "stream_state": None}

    params = stream.request_params(**inputs)

    assert params == {"perPage": 200, "from": "2020-08-01T00:00:00Z"}
Ejemplo n.º 3
0
def test_get_updated_state_returns_current_state_for_old_records(patch_incremental_base_class):
    stream = IncrementalPaystackStream(start_date=START_DATE)
    current_state = {stream.cursor_field: "2021-08-03"}
    inputs = {"current_stream_state": current_state, "latest_record": {stream.cursor_field: "2021-08-02T00:00:00Z"}}

    updated_state = stream.get_updated_state(**inputs)

    assert updated_state == current_state
Ejemplo n.º 4
0
def test_request_params_includes_incremental_start_point(patch_incremental_base_class):
    stream = IncrementalPaystackStream(start_date=START_DATE)
    inputs = {
        "stream_slice": None,
        "next_page_token": {"page": 37},
        "stream_state": {stream.cursor_field: "2021-09-02"},
    }

    params = stream.request_params(**inputs)

    assert params == {"perPage": 200, "page": 37, "from": "2021-09-02T00:00:00Z"}
Ejemplo n.º 5
0
def test_request_params_incremental_start_point_applies_lookback_window(
    patch_incremental_base_class, lookback_window_days, current_state, expected, message
):
    stream = IncrementalPaystackStream(start_date=START_DATE, lookback_window_days=lookback_window_days)
    inputs = {
        "stream_slice": None,
        "next_page_token": None,
        "stream_state": {stream.cursor_field: current_state},
    }

    params = stream.request_params(**inputs)

    assert params["perPage"] == 200
    assert params["from"] == expected, message
Ejemplo n.º 6
0
def test_supports_incremental(patch_incremental_base_class):
    stream = IncrementalPaystackStream(start_date=START_DATE)
    assert stream.supports_incremental
Ejemplo n.º 7
0
def test_stream_checkpoint_interval(patch_incremental_base_class):
    stream = IncrementalPaystackStream(start_date=START_DATE)
    assert stream.state_checkpoint_interval == math.inf
Ejemplo n.º 8
0
def test_source_defined_cursor(patch_incremental_base_class):
    stream = IncrementalPaystackStream(start_date=START_DATE)
    assert stream.source_defined_cursor