Skip to content

Commit

Permalink
test(datasets): make api.APIDataset doctests run (#448)
Browse files Browse the repository at this point in the history
Signed-off-by: Deepyaman Datta <[email protected]>
  • Loading branch information
deepyaman authored Nov 27, 2023
1 parent 82cd5e5 commit 6d38a2e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 10 deletions.
1 change: 0 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ dataset-tests: dataset-doctests
dataset-doctests:
# TODO(deepyaman): Fix as many doctests as possible (so that they run).
cd kedro-datasets && pytest kedro_datasets --doctest-modules --doctest-continue-on-failure --no-cov \
--ignore kedro_datasets/api/api_dataset.py \
--ignore kedro_datasets/databricks/managed_table_dataset.py \
--ignore kedro_datasets/matplotlib/matplotlib_writer.py \
--ignore kedro_datasets/pandas/deltatable_dataset.py \
Expand Down
15 changes: 6 additions & 9 deletions kedro-datasets/kedro_datasets/api/api_dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,18 +42,13 @@ class APIDataset(AbstractDataset[None, requests.Response]):
>>>
>>>
>>> dataset = APIDataset(
... url="https://quickstats.nass.usda.gov",
... url="https://api.spaceflightnewsapi.net/v4/articles",
... load_args={
... "params": {
... "key": "SOME_TOKEN",
... "format": "JSON",
... "commodity_desc": "CORN",
... "statisticcat_des": "YIELD",
... "agg_level_desc": "STATE",
... "year": 2000,
... "news_site": "NASA",
... "launch": "65896761-b6ca-4df3-9699-e077a360c52a", # Artemis I
... }
... },
... credentials=("username", "password"),
... )
>>> data = dataset.load()
Expand All @@ -65,7 +60,9 @@ class APIDataset(AbstractDataset[None, requests.Response]):
>>> example_table = '{"col1":["val1", "val2"], "col2":["val3", "val4"]}'
>>>
>>> dataset = APIDataset(
... method="POST", url="url_of_remote_server", save_args={"chunk_size": 1}
... method="POST",
... url="https://httpbin.org/post",
... save_args={"chunk_size": 1},
... )
>>> dataset.save(example_table)
Expand Down

0 comments on commit 6d38a2e

Please sign in to comment.