cra-window-rules / tests /test_get_data.py
mfebrizio's picture
create tests
a8baed5
raw
history blame
815 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"):
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}-01-31"
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)