import openpyxl from synthgen import dictionary from synthgen.config import Config from synthgen.ecp import write_ecp from synthgen.group import build_group def test_ecp_format(tmp_path): g = build_group(Config(group_size=6, prefix="DEMO2"), dictionary.load()) path = tmp_path / "ecp-DEMO2.xlsx" write_ecp(g, path) wb = openpyxl.load_workbook(path) assert wb.sheetnames == ["Выписки"] ws = wb["Выписки"] rows = list(ws.iter_rows(values_only=True)) assert list(rows[0]) == ["ИНН", "КПП", "iD ГК", "Базовый РФ ГК в CRM", "Группа компаний", "Организация", "ГСК", "ГСЗ", "Тип"] assert len(rows) - 1 == 6 for row, member in zip(rows[1:], g.members): assert row[0] == member.inn and row[1] == member.kpp and row[5] == member.name assert row[2] == "DEMO2-000001" and row[4] == "ГК DEMO2" assert row[6] == "Входит в ГСК" and row[8] == "ЮЛ" for r in ws.iter_rows(min_row=2, max_col=2): assert all(c.number_format == "@" and isinstance(c.value, str) for c in r)