package main import ( "context" "testing" "github.com/kami/maven/internal/router" ) // TestExtractWeatherLocation — any place he names comes through, not just the // six that used to be in a table (Vikunja #421). func TestExtractWeatherLocation(t *testing.T) { cases := []struct { utterance string def string want string }{ // The cities the table had, and the ones it silently dropped. {"какая погода в Москве", "Berlin", "Москве"}, {"какая погода в Казани", "Berlin", "Казани"}, {"погода в Тбилиси?", "Berlin", "Тбилиси"}, {"what's the weather in New York", "Berlin", "New York"}, {"тепло в Нижнем Новгороде?", "Berlin", "Нижнем Новгороде"}, // He named nothing: the configured default, and nothing at all when // there is no default. {"какая сегодня погода", "Berlin", "Berlin"}, {"какая сегодня погода", "", ""}, // "в" followed by something that is not a place stays the default — // the house sensors and the day words answer elsewhere. {"тепло в комнате?", "Berlin", "Berlin"}, {"какая погода в выходные", "Berlin", "Berlin"}, // The cases the three private copies of the lexicon were short by // (V-581): a weekday in a case the old map did not list, a part of the // day in one it did not list, and "в общем". {"какая погода в среде", "Berlin", "Berlin"}, {"какая погода в воскресеньях", "Berlin", "Berlin"}, {"какая погода в понедельникам", "Berlin", "Berlin"}, {"какая погода в общем", "Berlin", "Berlin"}, } for _, c := range cases { if got := extractWeatherLocation(c.utterance, c.def); got != c.want { t.Errorf("extractWeatherLocation(%q, %q) = %q, want %q", c.utterance, c.def, got, c.want) } } } // TestCalendarStepsAsideForWeather — the defect (Vikunja #474). "какая сегодня // погода в Москве?" answered "на 02.08.2026 ничего нет.": the calendar matches // on a day word alone, and it sits above the weather source. func TestCalendarStepsAsideForWeather(t *testing.T) { h, api := contQueryHandler() for _, u := range []string{ "какая сегодня погода в Москве?", "будет дождь завтра?", "сколько градусов сегодня?", } { if reply, ok := h.queryCalendar(context.Background(), &queryTurn{ dec: router.Decision{Intent: router.IntentQuery, Utterance: u}, }); ok { t.Errorf("the calendar claimed %q with %q", u, reply) } } if api.events != 0 { t.Errorf("CalendarEvents called %d times for weather questions, want 0", api.events) } // The agenda question it exists for still reaches it. if _, ok := h.queryCalendar(context.Background(), &queryTurn{ dec: router.Decision{Intent: router.IntentQuery, Utterance: "что у меня сегодня?"}, }); !ok { t.Fatal("the calendar stopped answering the agenda question") } }