smart tdee

This commit is contained in:
2026-06-16 04:38:23 +00:00
parent f2e98942ff
commit a3f01cd850
56 changed files with 2519 additions and 591 deletions
+22 -4
View File
@@ -7,6 +7,11 @@ def test_build_weather_dashboard_structure():
fake_weather = {
"ok": True,
"location": "Test City",
"data_source": "local",
"local_field_coverage": {"current": ["temperature_2m"], "hourly": [], "daily": []},
"field_coverage": {"current": ["temperature_2m"], "hourly": [], "daily": []},
"sync_hint": "",
"merged_fields": [],
"current": {
"time": "2026-06-13T12:00",
"temperature_c": 18.5,
@@ -27,12 +32,22 @@ def test_build_weather_dashboard_structure():
"conditions": "переменная облачность",
}
],
"daily": [
{
"date": "2026-06-14",
"label": "Завтра",
"temperature_max_c": 20.0,
"temperature_min_c": 12.0,
"conditions": "дождь",
}
],
}
with patch("app.homelab.openmeteo.OpenMeteoClient") as mock_cls:
client = mock_cls.return_value
client.fetch_current_and_hourly.return_value = fake_weather
client.fetch_forecast.return_value = fake_weather
client.rain_summary.return_value = "Существенных осадков в ближайшие часы не ожидается."
client.daily_summary.return_value = "Завтра: 1220°C"
client.cache_status.return_value = {
"has_data": True,
"cached": True,
@@ -40,18 +55,21 @@ def test_build_weather_dashboard_structure():
"age_sec": 10,
"ttl_sec": 300,
"expires_in_sec": 290,
"source": "local",
"merged_fields": [],
}
client.location_name = "Test City"
client.lat = 59.9
client.lon = 30.3
client.base_url = "http://openmeteo.test"
client.cache_ttl = 300
client.forecast_days = 7
result = build_weather_dashboard(hours_ahead=6)
result = build_weather_dashboard(hours_ahead=6, days_ahead=7)
assert result["weather"]["ok"] is True
assert "[Погода]" in result["assistant_context"]
assert "None" not in result["assistant_context"]
assert "temperature_2m" in result["available_fields"]["current"]
assert "get_weather" in result["assistant_tools"]
assert "daily" in result["available_fields"]
assert result["daily_summary"]
assert result["config"]["location"] == "Test City"