Skip to content

Commit 5f71127

Browse files
committed
Use current year in live economy tests
1 parent 53af3be commit 5f71127

1 file changed

Lines changed: 24 additions & 4 deletions

File tree

tests/integration/test_live_economy.py

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
1+
from datetime import date
12
import json
23
import math
34
from pathlib import Path
45

6+
CURRENT_YEAR = date.today().year
7+
58

69
def _load_reform_payload(filename: str) -> dict:
710
return json.loads(
@@ -22,9 +25,23 @@ def _pick_time_period(metadata: dict) -> str:
2225
period_names = [
2326
str(period["name"]) for period in metadata["economy_options"]["time_period"]
2427
]
25-
if "2025" in period_names:
26-
return "2025"
27-
return str(max(period_names))
28+
period_years = {
29+
int(period_name): period_name
30+
for period_name in period_names
31+
if period_name.isdigit()
32+
}
33+
34+
if CURRENT_YEAR in period_years:
35+
return period_years[CURRENT_YEAR]
36+
37+
previous_years = [year for year in period_years if year <= CURRENT_YEAR]
38+
if previous_years:
39+
return period_years[max(previous_years)]
40+
41+
if period_years:
42+
return period_years[min(period_years)]
43+
44+
return period_names[0]
2845

2946

3047
def test_live_economy_smoke(api_client, integration_probe_id, poll_live_endpoint):
@@ -66,9 +83,12 @@ def test_live_economy_smoke(api_client, integration_probe_id, poll_live_endpoint
6683

6784

6885
def test_live_utah_macro_reform(api_client, integration_probe_id, poll_live_endpoint):
69-
test_year = "2025"
7086
default_policy_id = 2
7187

88+
metadata_response = api_client.get("/us/metadata")
89+
metadata_response.raise_for_status()
90+
test_year = _pick_time_period(metadata_response.json()["result"])
91+
7292
policy_response = api_client.post(
7393
"/us/policy",
7494
json=_load_reform_payload("utah_reform.json"),

0 commit comments

Comments
 (0)