File size: 6,549 Bytes
9d29c62
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
"""
V231.17 - Lightweight verification script
Tests imports, syntax, and function signatures WITHOUT needing Google API key.
"""
import sys, os
sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
os.chdir(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))

passed = 0
failed = 0

def check(name, condition, detail=""):
    global passed, failed
    if condition:
        print(f"  โœ… {name}")
        passed += 1
    else:
        print(f"  โŒ {name} - {detail}")
        failed += 1

print("=" * 60)
print("๐Ÿ”ฌ BuddyMath V231.17 - Local Verification")
print("=" * 60)

# =========== 1. IMPORTS ===========
print("\n๐Ÿ“ฆ 1. Import Tests:")

try:
    import json
    check("json (stdlib)", True)
except Exception as e:
    check("json (stdlib)", False, str(e))

try:
    import json_repair
    check("json_repair", True)
except Exception as e:
    check("json_repair", False, str(e))

try:
    import micro_prompts
    check("micro_prompts imports", True)
except Exception as e:
    check("micro_prompts imports", False, str(e))

try:
    import problem_understanding
    check("problem_understanding imports", True)
except Exception as e:
    check("problem_understanding imports", False, str(e))

try:
    import topic_taxonomy
    check("topic_taxonomy imports", True)
except Exception as e:
    check("topic_taxonomy imports", False, str(e))

try:
    import validators
    check("validators imports", True)
except Exception as e:
    check("validators imports", False, str(e))

try:
    import prompts
    check("prompts imports", True)
except Exception as e:
    check("prompts imports", False, str(e))

# =========== 2. MICRO_PROMPTS ===========
print("\n๐Ÿ“ 2. micro_prompts.py Tests:")

try:
    # Test that json is available inside micro_prompts
    result = micro_prompts.get_general_prompt({"test": "data"})
    check("get_general_prompt() works (json.dumps OK)", isinstance(result, str) and len(result) > 20)
except NameError as e:
    check("get_general_prompt() works", False, f"NameError: {e}")
except Exception as e:
    check("get_general_prompt() works", False, str(e))

try:
    # Test CIRCLE_EQUATION micro-prompt
    result = micro_prompts.get_micro_prompt("CIRCLE_EQUATION", {"center": "(3,5)", "radius": "5"})
    check("CIRCLE_EQUATION micro-prompt", isinstance(result, str) and "ืžืขื’ืœ" in result)
except Exception as e:
    check("CIRCLE_EQUATION micro-prompt", False, str(e))

try:
    tokens = micro_prompts.get_prompt_token_count("CIRCLE_EQUATION")
    check(f"Token count for CIRCLE_EQUATION = {tokens}", tokens > 0)
except Exception as e:
    check("Token count", False, str(e))

# =========== 3. PROBLEM UNDERSTANDING ===========
print("\n๐Ÿง  3. problem_understanding.py Tests:")

try:
    prompt = problem_understanding.get_problem_understanding_prompt(
        "ืžืฆื ืžืฉื•ื•ืืช ืžืขื’ืœ", {"function_equations": [], "points": ["A"]}
    )
    check("Understanding prompt generation", isinstance(prompt, str) and len(prompt) > 50)
except Exception as e:
    check("Understanding prompt generation", False, str(e))

try:
    # Test JSON parsing with LaTeX - THE BUG WE FIXED
    test_json_with_latex = '{"problem_type": "GEOMETRY", "sub_questions": [{"id": "ื", "topic": "CIRCLE"}]}'
    result = problem_understanding.parse_understanding(test_json_with_latex)
    check("parse_understanding (clean JSON)", result["problem_type"] == "GEOMETRY")
except Exception as e:
    check("parse_understanding (clean JSON)", False, str(e))

try:
    # Test with escaped LaTeX that breaks standard json.loads
    test_bad_json = '{"type": "GEOMETRY", "eq": "\\Delta MOA"}'
    result = problem_understanding.parse_understanding(test_bad_json)
    check("parse_understanding (LaTeX JSON - json_repair)", "type" in result)
except Exception as e:
    check("parse_understanding (LaTeX JSON)", False, str(e))

try:
    valid = problem_understanding.validate_understanding({
        "problem_type": "CIRCLE",
        "sub_questions": [{"id": "ื", "question": "test", "topic": "CIRCLE"}],
        "solving_order": ["ื"]
    })
    check("validate_understanding", valid == True)
except Exception as e:
    check("validate_understanding", False, str(e))

# =========== 4. STRATEGY MANAGER ===========
print("\n๐ŸŽฏ 4. strategy_manager.py Tests:")

try:
    from strategy_manager import StrategyManager
    check("StrategyManager class imports", True)
except Exception as e:
    check("StrategyManager class imports", False, str(e))

try:
    import inspect
    sig = inspect.signature(StrategyManager.solve_with_strategy)
    params = list(sig.parameters.keys())
    check(f"solve_with_strategy params: {params}", "image_data" in params)
except Exception as e:
    check("solve_with_strategy signature", False, str(e))

try:
    sig = inspect.signature(StrategyManager._call_llm)
    params = list(sig.parameters.keys())
    check(f"_call_llm params: {params}", "image_data" in params and "category" in params)
except Exception as e:
    check("_call_llm signature", False, str(e))

# =========== 5. ORCHESTRATOR (without API key) ===========
print("\n๐Ÿ—๏ธ 5. orchestrator.py Tests:")

try:
    # Read the file and check for the kwarg fix
    with open("orchestrator.py", "r", encoding="utf-8") as f:
        orch_code = f.read()
    
    check("orchestrator.py reads image_bytes from kwargs", 
          "image_bytes" in orch_code and "kwargs.get('image_bytes'" in orch_code)
except Exception as e:
    check("orchestrator.py kwarg check", False, str(e))

try:
    check("orchestrator.py passes image_data to smart_solve",
          "image_data=image_data" in orch_code)
except Exception as e:
    check("orchestrator image_data pass-through", False, str(e))

try:
    check("orchestrator.py has V273.0+ version",
          "V273.0" in orch_code)
except Exception as e:
    check("orchestrator version", False, str(e))

# =========== 6. MAIN.PY ===========
print("\n๐ŸŒ 6. main.py Tests:")

try:
    with open("main.py", "r", encoding="utf-8") as f:
        main_code = f.read()
    
    check("main.py sends image_bytes to solve_problem",
          "image_bytes=image_bytes" in main_code)
except Exception as e:
    check("main.py image_bytes check", False, str(e))

# =========== SUMMARY ===========
print("\n" + "=" * 60)
total = passed + failed
print(f"๐Ÿ“Š Results: {passed}/{total} passed, {failed}/{total} failed")
if failed == 0:
    print("๐ŸŽ‰ ALL TESTS PASSED! Ready for deploy.")
else:
    print(f"โš ๏ธ {failed} test(s) FAILED - fix before deploy!")
print("=" * 60)