#!/usr/bin/env python3 """ Test script to debug the rapid fix logic with detailed step logging """ # Sample invalid RDF - your example SAMPLE_INVALID_RDF = """ Incomplete Title """ # Simulated validation results (what your validation showed) SAMPLE_VALIDATION_ERRORS = """ === Module: MonographDCTAP/Monograph_Work_Text.tsv === Overridden Conforms: False Results (4): Validation Result: Message: Less than 1 values on Work->bf:language Validation Result: Message: Less than 1 values on Work->bf:content Validation Result: Message: Less than 1 values on Work->bf:adminMetadata Validation Result: Message: Less than 1 values on Title->bf:mainTitle """ print("=" * 80) print("๐Ÿงช TESTING RAPID FIX LOGIC") print("=" * 80) print("\n๐Ÿ“„ INPUT RDF:") print(SAMPLE_INVALID_RDF) print("\nโŒ VALIDATION ERRORS:") print(SAMPLE_VALIDATION_ERRORS) print("\n" + "=" * 80) print("๐Ÿ”ง RUNNING RAPID FIX WITH DEBUG LOGGING") print("=" * 80) # Import the function import sys import os sys.path.insert(0, os.path.dirname(os.path.abspath(__file__))) try: from app import rapid_fix_missing_properties steps_log = [] result = rapid_fix_missing_properties( SAMPLE_INVALID_RDF, SAMPLE_VALIDATION_ERRORS, 'monograph', steps_log=steps_log ) print("\n๐Ÿ“‹ STEP-BY-STEP LOG:") print("-" * 80) for step in steps_log: print(step) print("\n" + "=" * 80) if result: print("โœ… RAPID FIX PRODUCED OUTPUT:") print("=" * 80) print(result) print("\n" + "=" * 80) print("๐Ÿ” ANALYSIS:") print("=" * 80) # Check what was added if "" in result and "" not in SAMPLE_INVALID_RDF: print("โœ… Added bf:language") if "" in result and "" not in SAMPLE_INVALID_RDF: print("โœ… Added bf:content") if "" in result and "" not in SAMPLE_INVALID_RDF: print("โœ… Added bf:adminMetadata") # Check if it has assigner if "" in result: print(" โœ… AdminMetadata includes bf:assigner") else: print(" โŒ AdminMetadata MISSING bf:assigner!") else: print("โŒ RAPID FIX RETURNED None") print("=" * 80) except Exception as e: print(f"\nโŒ ERROR: {e}") import traceback traceback.print_exc()