| import json |
| from pedagogical_builder import merge_and_verify_explanations, LLMSchemaError |
|
|
| def test_golden_merge(): |
| print("๐ Running The Golden Test: V2.5.3 Swiss Watch") |
|
|
| |
| sympy_nodes = [ |
| {"step_id": 1, "math": "f(x) = x^2", "logic": "ืืื ื ืืคืื ืงืฆืื"}, |
| {"step_id": 2, "math": "f'(x) = 2x", "logic": "ืืืืจื"} |
| ] |
|
|
| |
| llm_explanations = [ |
| {"step_id": 1, "pedagogical_explanation": "ื ืชืื ื ืื ื ืคืื ืงืฆืื ืจืืืืขืืช ืคืฉืืื."}, |
| {"step_id": 2, "pedagogical_explanation": "ื ืฉืชืืฉ ืืืื ืืืืงื ืืื ืืืฆืื ืืช ืื ืืืจืช."} |
| ] |
|
|
| try: |
| |
| final_nodes = merge_and_verify_explanations(sympy_nodes, llm_explanations) |
| |
| print(" โ
Merge Success!") |
| assert len(final_nodes) == 2 |
| assert final_nodes[1]["math"] == "f'(x) = 2x" |
| assert final_nodes[1]["pedagogical_explanation"] == "ื ืฉืชืืฉ ืืืื ืืืืงื ืืื ืืืฆืื ืืช ืื ืืืจืช." |
| |
| except LLMSchemaError as e: |
| print(f" โ Merge Failed: {e}") |
| assert False, "Golden Merge should have succeeded" |
|
|
| |
| print("\n๐ก๏ธ Testing Schema Enforcement (Swiss Watch Locks):") |
| |
| |
| try: |
| merge_and_verify_explanations(sympy_nodes, llm_explanations[:1]) |
| assert False, "Should have failed on length mismatch" |
| except LLMSchemaError: |
| print(" โ
Length Mismatch Guard - PASSED") |
|
|
| |
| llm_with_math = [ |
| {"step_id": 1, "pedagogical_explanation": "...", "math": "hacked math"}, |
| {"step_id": 2, "pedagogical_explanation": "..."} |
| ] |
| try: |
| merge_and_verify_explanations(sympy_nodes, llm_with_math) |
| assert False, "Should have failed on unexpected keys (math)" |
| except LLMSchemaError: |
| print(" โ
Key Enforcement Guard - PASSED") |
|
|
| |
| llm_shuffled = [ |
| {"step_id": 2, "pedagogical_explanation": "Step 2"}, |
| {"step_id": 1, "pedagogical_explanation": "Step 1"} |
| ] |
| try: |
| merge_and_verify_explanations(sympy_nodes, llm_shuffled) |
| assert False, "Should have failed on step order" |
| except LLMSchemaError: |
| print(" โ
Step Order Guard - PASSED") |
|
|
| print("\n๐ The Golden Test: V2.5.3 Swiss Watch - VERIFIED!") |
|
|
| if __name__ == "__main__": |
| test_golden_merge() |
|
|