Skip to content

Commit

Permalink
Add new test and remove now incorrect test
Browse files Browse the repository at this point in the history
  • Loading branch information
nikhilwoodruff committed Dec 10, 2021
1 parent 54b6608 commit 18cd0c1
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 4 deletions.
9 changes: 9 additions & 0 deletions tests/core/parameter_validation/string_parameter.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
description: A parameter with a string value
values:
2015-01-01: string, without metadata
2016-01-01:
value: string, with metadata
metadata:
unit: string
period: year
reference: none provided
8 changes: 7 additions & 1 deletion tests/core/parameter_validation/test_parameter_validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ def check_fails_with_message(file_name, keywords):
('indentation', {'Invalid YAML', 'indentation.yaml', 'line 2', 'mapping values are not allowed'}),
("wrong_date", {"Error parsing parameter file", "Properties must be valid YYYY-MM-DD instants"}),
('wrong_scale', {'Unexpected property', 'scale[1]', 'treshold'}),
('wrong_value', {'not one of the allowed types', 'wrong_value[2015-12-01]', '1A'}),
('unexpected_key_in_parameter', {'Unexpected property', 'unexpected_key'}),
('wrong_type_in_parameter', {'must be of type object'}),
('wrong_type_in_value_history', {'must be of type object'}),
Expand Down Expand Up @@ -58,3 +57,10 @@ def test_yaml_hierarchy():
parameters = ParameterNode('', directory_path = path)
parameters_at_instant = parameters('2016-01-01')
assert parameters_at_instant.node1.param == 1.0


def test_string_parameter():
path = os.path.join(BASE_DIR, 'string_parameter.yaml')
parameter = load_parameter_file(path, 'string_parameter')
assert parameter("2015-01-01") == "string, without metadata"
assert parameter("2016-01-01") == "string, with metadata"
3 changes: 0 additions & 3 deletions tests/core/parameter_validation/wrong_value.yaml

This file was deleted.

0 comments on commit 18cd0c1

Please sign in to comment.