dana-medical-site/internal/api/report_prodoctorov_sample_test.go
2026-10-14 13:33:13 +00:00

43 lines
1.9 KiB
Go
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

package api
import (
"os"
"testing"
"time"
)
// Opt-in регрессия на реальную выгрузку ПроДокторова «Онлайн-запись» (Appointment-2026-10.xlsx).
// Файл берётся только из локальной переменной окружения, в репозиторий не копируется и не печатается.
// Эталон снят независимым читателем (openpyxl): 9 записей и 8 уникальных телефонов.
// Месяц кабинета отбирается по дате создания записи (столбец «Дата»), а не по дате приёма
// («Запись на» заходит в следующий месяц), поэтому период 1С фильтруется именно по ней.
func TestProdoctorovSuppliedXLSXSample(t *testing.T) {
path := os.Getenv("DANA_PRODOCTOROV_SAMPLE_FILE")
if path == "" {
t.Skip("local source sample not supplied")
}
data, err := os.ReadFile(path)
if err != nil {
t.Fatal("cannot read local sample")
}
day := func(d, h, m int) time.Time { return time.Date(2026, 10, d, h, m, 0, 0, moscow) }
for _, c := range []struct {
name string
from, to time.Time
records, phn int
}{
{"весь месяц до 06.10", day(1, 0, 0), day(6, 0, 0), 9, 8},
{"два дня", day(2, 0, 0), day(4, 0, 0), 1, 1},
{"правая граница исключается", day(5, 0, 0), day(5, 13, 45), 3, 2},
{"правая граница чуть позже", day(5, 0, 0), day(5, 13, 46), 4, 3},
} {
phones, records, err := parseProdoctorovExport(data, c.from, c.to)
if err != nil {
t.Fatalf("%s: %v", c.name, err)
}
if records != c.records || len(phones) != c.phn {
t.Errorf("%s: записей %d, телефонов %d; ожидали %d и %d", c.name, records, len(phones), c.records, c.phn)
}
}
}