Skip to content

Commit

Permalink
Always include metadata in parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
fpagnoux committed Aug 3, 2018
1 parent 5a6af07 commit dc11f34
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
3 changes: 1 addition & 2 deletions openfisca_web_api_preview/loader/parameters.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,8 @@ def walk_node(node, parameters, path_fragments, country_package_metadata):
api_parameter = {
'description': getattr(child, "description", None),
'id': '.'.join(path_fragments + [child_name]),
'metadata': child.metadata
}
if child.metadata:
api_parameter['metadata'] = child.metadata
if child.file_path:
api_parameter['source'] = build_source_url(child.file_path, country_package_metadata)
if isinstance(child, Parameter):
Expand Down
10 changes: 5 additions & 5 deletions tests/web_api/test_parameters.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ def test_parameter_node():
response = subject.get('/parameter/benefits')
assert_equal(response.status_code, OK)
parameter = json.loads(response.data)
assert_equal(sorted(list(parameter.keys())), ['description', 'id', 'source', 'subparams'])
assert_equal(sorted(list(parameter.keys())), ['description', 'id', 'metadata', 'source', 'subparams'])
assert_equal(parameter['subparams'], {
'housing_allowance': {'description': 'Housing allowance amount (as a fraction of the rent)'},
'basic_income': {'description': 'Amount of the basic income'}
Expand All @@ -71,7 +71,7 @@ def test_stopped_parameter_values():
assert_equal(parameter['values'], {'2016-12-01': None, '2010-01-01': 0.25})


def test_bareme():
def test_scale():
response = subject.get('/parameter/taxes/social_security_contribution')
parameter = json.loads(response.data)
assert_equal(sorted(list(parameter.keys())), ['brackets', 'description', 'id', 'metadata', 'source'])
Expand All @@ -96,9 +96,9 @@ def test_routes_robustness():
'/parameter/': NOT_FOUND,
'/parameter/with-ÜNı©ød€': NOT_FOUND,
'/parameter/with%20url%20encoding': NOT_FOUND,
'/parameter/taxes.income_tax_rate/': OK,
'/parameter/taxes.income_tax_rate/too-much-nesting': NOT_FOUND,
'/parameter//taxes.income_tax_rate/': NOT_FOUND,
'/parameter/taxes/income_tax_rate/': OK,
'/parameter/taxes/income_tax_rate/too-much-nesting': NOT_FOUND,
'/parameter//taxes/income_tax_rate/': NOT_FOUND,
}

for route, code in expected_codes.items():
Expand Down

0 comments on commit dc11f34

Please sign in to comment.