From 98c1682c0b23b9e55ab5fadf3057c4d6d1c4bc9e Mon Sep 17 00:00:00 2001 From: Anthony Volk Date: Fri, 15 Mar 2024 17:32:26 +0200 Subject: [PATCH] test: Ensure that malformed cadence dates raise error --- .../parameters/operations/test_uprating.py | 51 +++++++++++++++++++ 1 file changed, 51 insertions(+) diff --git a/tests/core/parameters/operations/test_uprating.py b/tests/core/parameters/operations/test_uprating.py index 74469b5a..18ebfaa4 100644 --- a/tests/core/parameters/operations/test_uprating.py +++ b/tests/core/parameters/operations/test_uprating.py @@ -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,