from persistance.nodes import stable_persons def test_person_ids_survive_a_review_merge_and_split(fresh_platform): older = stable_persons({"one": ["a"]})["one"] newer = stable_persons({"two": ["b", "c"]})["two"] assert older != newer assert stable_persons({"merged": ["a", "b", "c"]}) == {"merged": older} with fresh_platform.connect() as connection: assert connection.exec_driver_sql( "select person_id, replaced_by from bronze.person_link" ).all() == [(newer, older)] split = {"small": ["a"], "large": ["b", "c"]} assigned = stable_persons(split) assert assigned["large"] == older assert assigned["small"] not in {older, newer} assert stable_persons(split) == assigned