Map Reject Codes First. Move One Classifier After.
Описание и применение
Заморозка таблицы фикстур и фиксация золотого снимка позволяют защитить импорт CSV от непреднамеренных изменений при рефакторинге.
Задача
Messy import scripts fail extracts for a measurable reason because validation rules are hidden inside file reads and writes, causing drift when refactoring.
Результат
By freezing a fixture table and recording a gold snapshot, the importer’s behavior becomes a contract that protects against accidental drift during refactoring.
Рабочий процесс
- 1. Build a CSV fixture that covers all branches (blank email, missing name, bad role, mixed‑case email, missing role).
- 2. Store the fixture text as a constant in the test module to avoid file I/O during asserts.
- 3. Run the importer with a recording writer that appends written records to a list.
- 4. Print the summary dict and written records to capture the first gold snapshot.
- 5. Verify the snapshot matches expected counts, reject codes, and canonical dicts.
- 6. Use the snapshot as a contract; any future refactor must preserve these outputs.
- 7. Optionally compute a hash of the snapshot for quick change detection.
Доказательства
Build one CSV that hits every branch once.
Run the importer against a recording writer.
Expected gold, derived from the fixture rules above: ...
- Дата записи: 2026-09-21T09:15:23.557Z