Skip to content

Commit

Permalink
tests: more download/metadata tests
Browse files Browse the repository at this point in the history
  • Loading branch information
isabelmeister committed Dec 11, 2024
1 parent c416da4 commit 189f2a8
Showing 1 changed file with 57 additions and 0 deletions.
57 changes: 57 additions & 0 deletions python-package/tests/test_download/test_metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,18 @@ def test_get_datasets_output():
out = metadata.get_datasets(dataset_id='', backend=backend)
assert isinstance(out, dict)

def test_get_datasets_output_with_input():
"""
Test if gets datasets output with an input
"""

backend = Backend()

out = metadata.get_datasets(dataset_name='br_me_caged', backend=backend)
## out: {'items': [], 'page': 1, 'page_size': 10, 'page_total': 0}
assert isinstance(out, dict)
assert len(out) > 0

def test_get_datasets_size():
"""
Test if gets datasets correct output length
Expand All @@ -36,6 +48,18 @@ def test_get_tables_output():
out = metadata.get_tables(dataset_id='', backend=backend)
assert isinstance(out, dict)

def test_get_tables_output_with_input():
"""
Test if gets tables output with an input
"""

backend = Backend()

out = metadata.get_tables(table_name='br_me_caged', backend=backend)
## out: {'items': [], 'page': 1, 'page_size': 10, 'page_total': 0}
assert isinstance(out, dict)
assert len(out) > 0

def test_get_tables_size():
"""
Test if gets tables correct output length
Expand All @@ -57,6 +81,18 @@ def test_get_columns_output():
out = metadata.get_columns(table_id='', backend=backend)
assert isinstance(out, dict)

def test_get_columns_output_with_input():
"""
Test if gets columns output with an input
"""

backend = Backend()

out = metadata.get_columns(columns_name='microdados_antigos', backend=backend)
## out: {'items': [], 'page': 1, 'page_size': 10, 'page_total': 0}
assert isinstance(out, dict)
assert len(out) > 0

def test_get_columns_size():
"""
Test if gets columns correct output length
Expand All @@ -79,6 +115,27 @@ def test_search_output():
assert isinstance(out, list)
assert isinstance(out[0], dict)

def test_search_output_with_input():
"""
Test if gets search output with an input
"""

backend = Backend()

out = metadata.search(q='data', backend=backend)
print(out[0])
print(len(out))
print(out[0].keys())
assert isinstance(out, list)
assert isinstance(out[0], dict)
assert 'slug' in out[0].keys()
assert 'name' in out[0].keys()
assert 'description' in out[0].keys()
assert 'n_tables' in out[0].keys()
assert 'n_raw_data_sources' in out[0].keys()
assert 'n_information_requests' in out[0].keys()
assert 'organization' in out[0].keys()

def test_search_size():
"""
Test if gets search correct output length
Expand Down

0 comments on commit 189f2a8

Please sign in to comment.