#!/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()