Example #1
0
def test_display_report_stream_slices_full_refresh(config):
    stream = SponsoredDisplayReportStream(config,
                                          None,
                                          authenticator=mock.MagicMock())
    slices = stream.stream_slices(SyncMode.full_refresh,
                                  cursor_field=stream.cursor_field)
    assert slices == [{"reportDate": "20210730"}]
Example #2
0
def test_display_report_stream_slices_incremental(test_config):
    config = AmazonAdsConfig(**test_config)
    stream = SponsoredDisplayReportStream(config,
                                          None,
                                          authenticator=mock.MagicMock())
    stream_state = {"reportDate": "20210726"}
    slices = stream.stream_slices(SyncMode.incremental,
                                  cursor_field=stream.cursor_field,
                                  stream_state=stream_state)
    assert slices == [
        {
            "reportDate": "20210723"
        },
        {
            "reportDate": "20210724"
        },
        {
            "reportDate": "20210725"
        },
        {
            "reportDate": "20210726"
        },
        {
            "reportDate": "20210727"
        },
        {
            "reportDate": "20210728"
        },
        {
            "reportDate": "20210729"
        },
        {
            "reportDate": "20210730"
        },
    ]
    stream_state = {"reportDate": "20210730"}
    slices = stream.stream_slices(SyncMode.incremental,
                                  cursor_field=stream.cursor_field,
                                  stream_state=stream_state)
    assert slices == [
        {
            "reportDate": "20210727"
        },
        {
            "reportDate": "20210728"
        },
        {
            "reportDate": "20210729"
        },
        {
            "reportDate": "20210730"
        },
    ]

    stream_state = {"reportDate": "20210731"}
    slices = stream.stream_slices(SyncMode.incremental,
                                  cursor_field=stream.cursor_field,
                                  stream_state=stream_state)
    assert slices == [
        {
            "reportDate": "20210728"
        },
        {
            "reportDate": "20210729"
        },
        {
            "reportDate": "20210730"
        },
    ]

    slices = stream.stream_slices(SyncMode.incremental,
                                  cursor_field=stream.cursor_field,
                                  stream_state={})
    assert slices == [{"reportDate": "20210730"}]

    slices = stream.stream_slices(SyncMode.incremental,
                                  cursor_field=None,
                                  stream_state={})
    assert slices == [{"reportDate": "20210730"}]