rodunia/llm-research-app
0
1#!/usr/bin/env python32"""Test that render.py works with enhanced YAMLs."""3 4from pathlib import Path5from runner.render import load_product_yaml, render_prompt6 7def test_product(product_id: str):8 """Test rendering a product with all templates."""9 print(f"\n{'='*60}")10 print(f"Testing: {product_id}")11 print(f"{'='*60}")12 13 # Load product YAML14 yaml_path = Path(f"products/{product_id}.yaml")15 product_data = load_product_yaml(yaml_path)16 17 print(f"✓ Loaded YAML: {product_data['name']}")18 print(f" Keys present: {sorted(product_data.keys())}")19 20 # Test all three updated templates21 templates = ["digital_ad.j2", "faq.j2", "blog_post_promo.j2"]22 results = {}23 24 for template in templates:25 try:26 rendered = render_prompt(product_data, template, trap_flag=False)27 print(f"✓ Rendered {template}: {len(rendered)} chars")28 results[template] = True29 except Exception as e:30 print(f"✗ Failed {template}: {e}")31 results[template] = False32 33 return all(results.values())34 35if __name__ == "__main__":36 products = [37 "supplement_melatonin",38 "cryptocurrency_corecoin",39 "smartphone_mid"40 ]41 42 results = {}43 for product_id in products:44 try:45 results[product_id] = test_product(product_id)46 except Exception as e:47 print(f"✗ ERROR testing {product_id}: {e}")48 results[product_id] = False49 50 print(f"\n{'='*60}")51 print("SUMMARY")52 print(f"{'='*60}")53 for product_id, success in results.items():54 status = "✓ PASS" if success else "✗ FAIL"55 print(f"{status}: {product_id}")56 57 all_passed = all(results.values())58 if all_passed:59 print("\n🎉 All tests passed! render.py works with enhanced YAMLs.")60 else:61 print("\n❌ Some tests failed.")62 exit(1)63 