| from src.analyzer import ImageAnalyzer |
| import json |
|
|
| def test_legacy_separation(): |
| analyzer = ImageAnalyzer() |
| |
| |
| site_data = { |
| "https://example.com/mixed": [ |
| {"src": "bad1.jpg", "alt": "logo"}, |
| {"src": "bad2.jpg", "alt": "product-123.jpg"}, |
| {"src": "bad3.jpg", "alt": "a"}, |
| {"src": "bad4.jpg", "alt": "ok"}, |
| {"src": "bad5.jpg", "alt": "one"}, |
| {"src": "good.jpg", "alt": "Great Product Photo"}, |
| ] |
| } |
| |
| print("Running Legacy Separation Test...") |
| report = analyzer.analyze_site(site_data) |
| |
| print("--- Summary ---") |
| print(json.dumps(report['summary'], indent=2)) |
| |
| print("\n--- Checking for keys ---") |
| details = report['details'][0] |
| |
| if "images_with_short_alt" not in details: |
| print("SUCCESS: 'images_with_short_alt' key is ABSENT.") |
| else: |
| print("FAILURE: 'images_with_short_alt' key is PRESENT.") |
| exit(1) |
| |
| if "short_alt_count" not in details: |
| print("SUCCESS: 'short_alt_count' key is ABSENT.") |
| else: |
| print("FAILURE: 'short_alt_count' key is PRESENT.") |
| exit(1) |
| |
| print(f"\nPoor Quality Count: {details['poor_quality_count']}") |
| print("\n--- Poor Quality List Content ---") |
| for img in details['images_with_poor_alt']: |
| print(f" [{img['reason']}] {img['alt']}") |
| |
| if __name__ == "__main__": |
| test_legacy_separation() |
|
|