Skip to content

Commit f7082e2

Browse files
committed
test: Ensure malformed effective dates fail
1 parent 9eed206 commit f7082e2

File tree

1 file changed

+54
-1
lines changed

1 file changed

+54
-1
lines changed

tests/core/parameters/operations/test_uprating.py

Lines changed: 54 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,7 @@ def test_parameter_uprating_two_year_offset():
273273
assert uprated.to_be_uprated("2020-04-01") == 32
274274
assert uprated.to_be_uprated("2021-04-01") == 64
275275

276-
def test_parameter_uprating_cadence_custom_start():
276+
def test_parameter_uprating_cadence_custom_effective():
277277
"""
278278
Test custom start date for uprating
279279
"""
@@ -329,6 +329,59 @@ def test_parameter_uprating_cadence_custom_start():
329329
assert uprated.to_be_uprated("2020-04-01") == 8
330330
assert uprated.to_be_uprated("2021-04-01") == 16
331331

332+
def test_parameter_uprating_cadence_custom_effective_malformed():
333+
"""
334+
Test that malformed custom effective date for uprating raises error
335+
"""
336+
337+
from policyengine_core.parameters import ParameterNode
338+
339+
# Create the parameter
340+
341+
root = ParameterNode(
342+
data={
343+
"to_be_uprated": {
344+
"description": "Example parameter",
345+
"values": {
346+
"2015-04-01": 1,
347+
"2016-04-01": 2,
348+
"2017-04-01": 4
349+
},
350+
"metadata": {
351+
"uprating": {
352+
"parameter": "uprater",
353+
"at_defined_interval": {
354+
"enactment": "0002-04-01",
355+
"start": "0000-10-01",
356+
"end": "0001-10-01",
357+
"effective": "dworkin"
358+
}
359+
},
360+
},
361+
},
362+
"uprater": {
363+
"description": "Uprater",
364+
"values": {
365+
"2015-10-01": 1,
366+
"2015-12-01": 1,
367+
"2016-10-01": 2,
368+
"2016-12-01": 1,
369+
"2017-10-01": 4,
370+
"2017-12-01": 1,
371+
"2018-10-01": 8,
372+
"2019-10-01": 16,
373+
"2020-10-01": 32
374+
},
375+
},
376+
}
377+
)
378+
379+
from policyengine_core.parameters import uprate_parameters
380+
381+
with pytest.raises(ValueError):
382+
uprated = uprate_parameters(root)
383+
384+
332385
def test_parameter_uprating_missing_data():
333386
"""
334387
Test that, if missing a cadence start value,

0 commit comments

Comments
 (0)