-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
132 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
airbyte-integrations/connectors/source-nasa/integration_tests/abnormal_state.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
{ | ||
"todo-stream-name": { | ||
"todo-field-name": "todo-abnormal-value" | ||
"nasa-apod": { | ||
"date": "9999-12-31" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
airbyte-integrations/connectors/source-nasa/integration_tests/sample_state.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
{ | ||
"todo-stream-name": { | ||
"todo-field-name": "value" | ||
"nasa-apod": { | ||
"date": "2022-10-15" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
50 changes: 50 additions & 0 deletions
50
airbyte-integrations/connectors/source-nasa/unit_tests/test_incremental_streams.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
# | ||
# Copyright (c) 2022 Airbyte, Inc., all rights reserved. | ||
# | ||
|
||
|
||
from datetime import datetime, timedelta | ||
from airbyte_cdk.models import SyncMode | ||
from pytest import fixture | ||
from source_nasa.source import NasaApod | ||
|
||
config = {"api_key": "foobar"} | ||
|
||
|
||
@fixture | ||
def patch_incremental_base_class(mocker): | ||
# Mock abstract methods to enable instantiating abstract class | ||
mocker.patch.object(NasaApod, "path", "v0/example_endpoint") | ||
mocker.patch.object(NasaApod, "primary_key", "test_primary_key") | ||
mocker.patch.object(NasaApod, "__abstractmethods__", set()) | ||
|
||
|
||
def test_cursor_field(patch_incremental_base_class): | ||
stream = NasaApod(config=config) | ||
expected_cursor_field = "date" | ||
assert stream.cursor_field == expected_cursor_field | ||
|
||
|
||
def test_stream_slices(patch_incremental_base_class): | ||
stream = NasaApod(config=config) | ||
start_date = datetime.now() - timedelta(days=3) | ||
inputs = {"sync_mode": SyncMode.incremental, "cursor_field": ["date"], "stream_state": {"date": start_date.strftime("%Y-%m-%d")}} | ||
expected_stream_slice = [{"date": (start_date + timedelta(days=x)).strftime("%Y-%m-%d")} for x in range(4)] | ||
assert stream.stream_slices(**inputs) == expected_stream_slice | ||
|
||
|
||
def test_supports_incremental(patch_incremental_base_class, mocker): | ||
mocker.patch.object(NasaApod, "cursor_field", "dummy_field") | ||
stream = NasaApod(config=config) | ||
assert stream.supports_incremental | ||
|
||
|
||
def test_source_defined_cursor(patch_incremental_base_class): | ||
stream = NasaApod(config=config) | ||
assert stream.source_defined_cursor | ||
|
||
|
||
def test_stream_checkpoint_interval(patch_incremental_base_class): | ||
stream = NasaApod(config=config) | ||
expected_checkpoint_interval = None | ||
assert stream.state_checkpoint_interval == expected_checkpoint_interval |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters