from pathlib import Path from composer_ans.pipeline import CompositionPipeline from composer_ans.types import CompositionContext THES = Path(__file__).resolve().parents[1] / "THES" def test_pipeline_single_neural_step_returns_structured_result() -> None: pipeline = CompositionPipeline.from_legacy_data(THES) step = pipeline.neural_step(CompositionContext()) assert len(step.context.notes) == 5 assert 0 <= step.context.candidate_note <= 8 assert isinstance(step.accepted, bool) assert isinstance(step.objects, bool) assert step.elapsed_seconds >= 0.0 def test_pipeline_step_until_accepted_accepts_note() -> None: pipeline = CompositionPipeline.from_legacy_data(THES) step = pipeline.step_until_accepted(CompositionContext(), max_attempts=500) assert step.accepted is True assert 1 <= step.context.notes[-1] <= 8 assert step.context.note_count == 1 def test_pipeline_compose_returns_requested_number_of_notes() -> None: pipeline = CompositionPipeline.from_legacy_data(THES) record = pipeline.compose(max_notes=3) assert len(record.notes) == 3 assert len(record.per_note_seconds) == 3 assert record.total_seconds >= 0.0 assert all(1 <= note <= 8 for note in record.notes)