Commit bb595639 authored by Christophe Benz's avatar Christophe Benz
Browse files

Merge branch 'issue_660-crash_when_trying_to_get_unused_dimensions_labels'

parents a1463b6b fed8c2e2
......@@ -231,7 +231,8 @@ def fetch_series_by_api_link(api_link, max_nb_series=None,
for dim_code in dataset_dimensions['dimensions_codes_order']}
# Add dimensions values labels to current series
if 'dimensions_values_labels' in dataset_dimensions:
for dimension_code, dimension_label in dataset_dimensions_labels.items():
for dimension_code in series['dimensions']:
dimension_label = dataset_dimensions_labels[dimension_code]
dimension_value_code = series_dims_by_dataset_code[complete_dataset_code][series['series_code']][dimension_code]
flat_series[dimension_label] = dict(dataset_dimensions['dimensions_values_labels']
[dimension_code])[dimension_value_code]
......
......@@ -47,7 +47,7 @@ interactions:
Content-Type:
- application/json
Date:
- Wed, 31 Mar 2021 15:06:21 GMT
- Wed, 31 Mar 2021 15:24:46 GMT
Server:
- nginx/1.14.2
status:
......
......@@ -288,3 +288,14 @@ def test_fetch_series_without_dimensions_labels_nor_dimensions_values_labels():
# dimensions_labels column shouldn't exist
assert not 'Data Type' in list(df.columns)
@pytest.mark.vcr(decode_compressed_response=True)
def test_fetch_series_that_dont_use_all_defined_dimensions_in_dataset():
"""https://git.nomics.world/dbnomics-fetchers/management/-/issues/660"""
# Thanks to @pytest.mark.vcr decorator, this request result will be read from cassettes yaml file (the one that match the test function name)
df = fetch_series('BEA/NIPA-T11706/A191RX-Q')
# Check that all expected columns are present
expected_columns = {'@frequency', 'provider_code', 'dataset_code', 'dataset_name', 'series_code', 'series_name', 'original_period', 'period', 'original_value', 'value', 'concept', 'FREQ', 'metric', 'unit', 'Concept', 'Frequency', 'Metric', 'Unit'}
assert expected_columns & set(df.columns) == expected_columns, set(df.columns)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment