Spaces:
Running
Running
| """Mapping unit tests for Supabase column bridges.""" | |
| from __future__ import annotations | |
| from app.services.supabase_service import project_from_supabase, project_to_supabase | |
| def test_roundtrip_preserves_canonical_fields(): | |
| canonical = { | |
| "id": "uuid-1", | |
| "object_name": "Жилой дом № 5", | |
| "contract_no": "12-2026/БН", | |
| "client": "ООО «Заказчик»", | |
| "technical_supervisor": "Иванов И.И.", | |
| "contractor": "ООО «Подряд»", | |
| "work_producer": "Петров П.П.", | |
| "chief_engineer": "Сидоров С.С.", | |
| "created_at": "2026-06-22T10:00:00+00:00", | |
| } | |
| row = project_to_supabase(canonical) | |
| assert row["name"] == "Жилой дом № 5" | |
| assert row["contract_number"] == "12-2026/БН" | |
| roundtripped = project_from_supabase({ | |
| "id": "uuid-1", | |
| "name": row["name"], | |
| "contract_number": row["contract_number"], | |
| "client": row["client"], | |
| "tech_supervisor": row["tech_supervisor"], | |
| "contractor": row["contractor"], | |
| "responsible_foreman": row["responsible_foreman"], | |
| "chief_engineer": row["chief_engineer"], | |
| "created_at": row["created_at"], | |
| }) | |
| assert roundtripped["id"] == "uuid-1" | |
| assert roundtripped["object_name"] == "Жилой дом № 5" | |
| assert roundtripped["work_producer"] == "Петров П.П." | |
| # canonical fields not in pre-existing schema are dropped naturally | |
| assert "start_date" not in roundtripped | |