Spaces:
Sleeping
Sleeping
| #!/usr/bin/env python3 | |
| """ | |
| Test script to verify the file upload functionality works correctly. | |
| """ | |
| import json | |
| import sys | |
| import os | |
| # Add src directory to path | |
| sys.path.insert(0, os.path.join(os.path.dirname(__file__), 'src')) | |
| from structure_analysis import detect_summary_fields, classify_data_structure, get_hierarchy_summary | |
| def test_analysis_functions(): | |
| """Test the analysis functions with sample data.""" | |
| # Load test data | |
| with open('test_data.json', 'r') as f: | |
| data = json.load(f) | |
| print("=== Testing Analysis Functions ===") | |
| print(f"Data loaded: {type(data)}") | |
| print(f"Data keys: {list(data.keys())}") | |
| print() | |
| # Test detect_summary_fields | |
| print("Testing detect_summary_fields...") | |
| summary_fields = detect_summary_fields(data) | |
| print(f"Summary fields found: {summary_fields}") | |
| print() | |
| # Test classify_data_structure | |
| print("Testing classify_data_structure...") | |
| classification = classify_data_structure(data) | |
| print(f"Classification result: {classification}") | |
| print() | |
| # Test get_hierarchy_summary | |
| print("Testing get_hierarchy_summary...") | |
| hierarchy_summary = get_hierarchy_summary(data) | |
| print(f"Hierarchy summary: {hierarchy_summary}") | |
| print() | |
| # Test the full analysis function | |
| print("Testing full analysis...") | |
| try: | |
| from streamlit_app import analyze_with_llm | |
| analysis_result = analyze_with_llm(data, "rotation_enabled") | |
| print("β Analysis completed successfully!") | |
| print(f"Analysis keys: {list(analysis_result.keys())}") | |
| print(f"Recommended fields: {analysis_result.get('recommended_fields', [])}") | |
| except Exception as e: | |
| print(f"β Analysis failed: {e}") | |
| import traceback | |
| traceback.print_exc() | |
| if __name__ == "__main__": | |
| test_analysis_functions() | |