from pathlib import Path from semantic_kernel import index_project from transaction_topology import routines_touching_target, transaction_targets, transaction_write_sets def test_transaction_write_sets_find_register_writes(tmp_path: Path): module = tmp_path / "demo_module.bsl" module.write_text( """ Процедура Проведение() Движения.ОстаткиТоваров.Записать(); КонецПроцедуры """, encoding="utf-8", ) snapshot = index_project(tmp_path, project_id="demo") write_sets = transaction_write_sets(snapshot) assert write_sets[0].routine.name == "Проведение" assert write_sets[0].writes[0].name == "ОстаткиТоваров" assert routines_touching_target(snapshot, "ОстаткиТоваров")[0].name == "Проведение" def test_transaction_targets_group_multiple_writers_by_register(tmp_path: Path): module = tmp_path / "demo_module.bsl" module.write_text( """ Процедура Проведение() Движения.ОстаткиТоваров.Записать(); КонецПроцедуры Процедура Корректировка() Набор = РегистрыНакопления.ОстаткиТоваров.СоздатьНаборЗаписей(); Набор.Записать(); КонецПроцедуры """, encoding="utf-8", ) snapshot = index_project(tmp_path, project_id="transaction-targets") targets = transaction_targets(snapshot) assert [target.target.qualified_name for target in targets] == ["РегистрНакопления.ОстаткиТоваров"] assert {routine.name for routine in targets[0].routines} == {"Проведение", "Корректировка"}