442d3ec08e
"напомни мне позвонить маме в семь вечера" answered "не получилось разобрать время напоминания", while "в 19:00" set the reminder. Reminders arrive through speech, and speech says the hour in words, so this was the ordinary case failing and the typed one working. SpellOutDigits rewrites a spoken number as digits, but only when a time word stands beside it — "в три часа" becomes "в 3 часа" and "купить три яблока" is left alone. Both parsers see it: dateparser already rewrites "7 вечера" to "7 pm" and never saw a digit to rewrite, and the stub floor now reads the qualifier itself.
39 lines
1.4 KiB
Go
39 lines
1.4 KiB
Go
package router
|
|
|
|
import (
|
|
"context"
|
|
"testing"
|
|
"time"
|
|
)
|
|
|
|
func TestSpellOutDigits(t *testing.T) {
|
|
for _, tc := range []struct{ in, want string }{
|
|
{"напомни мне позвонить маме в семь вечера", "напомни мне позвонить маме в 7 вечера"},
|
|
{"в три часа дня", "в 3 часа дня"},
|
|
{"напомни в половине шестого", "напомни в половине шестого"},
|
|
{"через двадцать минут", "через 20 минут"},
|
|
// Untouched: no time word stands beside the number.
|
|
{"купить три яблока", "купить три яблока"},
|
|
{"семь раз отмерь", "семь раз отмерь"},
|
|
{"напомни в 19:00", "напомни в 19:00"},
|
|
{"", ""},
|
|
} {
|
|
if got := SpellOutDigits(tc.in); got != tc.want {
|
|
t.Errorf("SpellOutDigits(%q) = %q, want %q", tc.in, got, tc.want)
|
|
}
|
|
}
|
|
}
|
|
|
|
// The utterance from the QA sitting that named this bug: the numeric form
|
|
// parsed and the spoken form did not.
|
|
func TestStubParsesASpokenHour(t *testing.T) {
|
|
now := time.Date(2026, 8, 2, 9, 0, 0, 0, time.Local)
|
|
got, ok, err := StubDateTimeParser{}.Parse(context.Background(), "напомни мне позвонить маме в семь вечера", now)
|
|
if err != nil || !ok {
|
|
t.Fatalf("Parse ok=%v err=%v, want a time", ok, err)
|
|
}
|
|
if got.Hour() != 19 {
|
|
t.Fatalf("hour = %d, want 19", got.Hour())
|
|
}
|
|
}
|