Skip to content

Commit

Permalink
test: Ensure that malformed cadence dates raise error
Browse files Browse the repository at this point in the history
  • Loading branch information
anth-volk committed Mar 15, 2024
1 parent f7082e2 commit 98c1682
Showing 1 changed file with 51 additions and 0 deletions.
51 changes: 51 additions & 0 deletions tests/core/parameters/operations/test_uprating.py
Original file line number Diff line number Diff line change
Expand Up @@ -382,6 +382,57 @@ def test_parameter_uprating_cadence_custom_effective_malformed():
uprated = uprate_parameters(root)


def test_parameter_uprating_cadence_date_malformed():
"""
Test that malformed cadence start/end date for uprating raises error
"""

from policyengine_core.parameters import ParameterNode

# Create the parameter

root = ParameterNode(
data={
"to_be_uprated": {
"description": "Example parameter",
"values": {
"2015-04-01": 1,
"2016-04-01": 2,
"2017-04-01": 4
},
"metadata": {
"uprating": {
"parameter": "uprater",
"at_defined_interval": {
"enactment": "0002-04-01",
"start": "0000-10",
"end": "0001-10-01",
}
},
},
},
"uprater": {
"description": "Uprater",
"values": {
"2015-10-01": 1,
"2015-12-01": 1,
"2016-10-01": 2,
"2016-12-01": 1,
"2017-10-01": 4,
"2017-12-01": 1,
"2018-10-01": 8,
"2019-10-01": 16,
"2020-10-01": 32
},
},
}
)

from policyengine_core.parameters import uprate_parameters

with pytest.raises(SyntaxError):
uprated = uprate_parameters(root)

def test_parameter_uprating_missing_data():
"""
Test that, if missing a cadence start value,
Expand Down

0 comments on commit 98c1682

Please sign in to comment.