import pytest from rdkit import Chem from macro_lactone_toolkit.validation.isotope_utils import ( build_fragment_with_isotope, extract_isotope_position, ) def test_build_fragment_with_isotope(): # Create a simple test molecule: ethyl group attached to position 5 mol = Chem.MolFromSmiles("CCCC(CC)CCC") # Position 4 (0-indexed) has ethyl assert mol is not None side_chain_atoms = [4, 5] # The ethyl group atoms side_chain_start = 4 ring_atom = 3 cleavage_pos = 5 labeled, plain, bond_type = build_fragment_with_isotope( mol, side_chain_atoms, side_chain_start, ring_atom, cleavage_pos ) assert labeled is not None assert plain is not None assert bond_type == "SINGLE" # Check isotope was set extracted_pos = extract_isotope_position(labeled) assert extracted_pos == cleavage_pos # Plain should have no isotope extracted_plain = extract_isotope_position(plain) assert extracted_plain == 0