Skip to content

Commit

Permalink
Merge pull request #1386 from harshitbansal05/develop
Browse files Browse the repository at this point in the history
Add test and doc string for get_datasets_upstream
  • Loading branch information
henrykironde committed Sep 10, 2019
2 parents 51f7751 + c4a63fa commit b01e42d
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 2 deletions.
4 changes: 3 additions & 1 deletion retriever/lib/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
from .fetch import fetch
from .scripts import reload_scripts
from .scripts import get_script_upstream
from .scripts import get_dataset_names_upstream

__all__ = [
'check_for_updates',
Expand All @@ -36,5 +37,6 @@
'install_json',
'install_xml',
'fetch',
'get_script_upstream'
'get_script_upstream',
'get_dataset_names_upstream'
]
6 changes: 5 additions & 1 deletion retriever/lib/scripts.py
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,11 @@ def get_script_version_upstream(dataset, repo=REPOSITORY):


def get_dataset_names_upstream(keywords=None, licenses=None, repo=REPOSITORY):
"""Search all datasets upstream by keywords and licenses."""
"""Search all datasets upstream by keywords and licenses. If the keywords
or licenses argument is passed, Github's search API is used for looking
in the repositories. Else, the version.txt file is read and the script
names are then returned.
"""
if not keywords and not licenses:
version_file_request = get_data_upstream(repo + "version.txt")
if not version_file_request:
Expand Down
10 changes: 10 additions & 0 deletions test/test_retriever.py
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,16 @@ def test_dataset_names():
assert 'mammal-masses' in dataset_names


def test_dataset_names_upstream():
"""Check if upstream datasets include a known value"""
datasets = rt.get_dataset_names_upstream()
assert 'portal' in datasets
license_datasets = rt.get_dataset_names_upstream(licenses=['CC0-1.0'])
assert 'bird-size' in license_datasets
keyword_datasets = rt.get_dataset_names_upstream(keywords=['plants'])
assert 'biodiversity-response' in keyword_datasets


def test_drop_statement():
"""Test the creation of drop statements."""
assert test_engine.drop_statement(
Expand Down

0 comments on commit b01e42d

Please sign in to comment.