from __future__ import annotations import json import pandas as pd import pytest from macro_lactone_toolkit import MacroLactoneAnalyzer, MacrolactoneFragmenter from .helpers import ( build_ambiguous_smiles, build_macrolactone, build_non_standard_ring_atom_macrolactone, ) def test_visualization_exports_numbered_svg_and_png(tmp_path): from macro_lactone_toolkit.visualization import ( numbered_molecule_svg, save_fragment_png, save_numbered_molecule_png, ) built = build_macrolactone(16, {5: "methyl"}) fragment = MacrolactoneFragmenter().fragment_molecule(built.smiles, parent_id="viz_1").fragments[0] svg = numbered_molecule_svg(built.smiles) assert " 0 fragment_path = tmp_path / "fragment.png" returned_fragment_path = save_fragment_png(fragment.fragment_smiles_labeled, fragment_path) assert returned_fragment_path == fragment_path assert fragment_path.exists() assert fragment_path.stat().st_size > 0 def test_visualization_supports_allowed_ring_atom_type_filtering(): from macro_lactone_toolkit.visualization import numbered_molecule_svg hetero = build_non_standard_ring_atom_macrolactone() svg = numbered_molecule_svg(hetero.smiles, allowed_ring_atom_types=["C", "N"]) assert "