cra-window-rules / tests /test_get_data.py
Mark Febrizio
Documentation (#24)
fe4f734 unverified
raw
history blame
845 Bytes
from datetime import date
from modules.get_rules_in_window import (
get_date_range,
get_rules,
)
def test_get_date_range(start_str: str = "2024-05-01", end_mmdd: str = "01-03"):
start_date = date.fromisoformat(start_str)
end_year = start_date.year + 1
dates_str = get_date_range(start_str)
assert isinstance(dates_str, dict)
assert (
dates_str.get("start") == start_str
and dates_str.get("end") == f"{end_year}-{end_mmdd}"
and dates_str.get("transition_year") == end_year
)
def test_get_rules(
date_range: dict = {
"start": "2024-05-01",
"end": "2024-05-10",
"transition_year": 2025,
}
):
results = get_rules(date_range)
assert isinstance(results, list)
assert all(isinstance(item, dict) for item in results)