refact: rm test file
This commit is contained in:
112
test_omml_api.py
112
test_omml_api.py
@@ -1,112 +0,0 @@
|
||||
"""Test script for OMML conversion API endpoint."""
|
||||
|
||||
import requests
|
||||
import json
|
||||
|
||||
|
||||
def test_latex_to_omml():
|
||||
"""Test the /convert/latex-to-omml endpoint."""
|
||||
|
||||
# Test cases
|
||||
test_cases = [
|
||||
{
|
||||
"name": "Simple fraction",
|
||||
"latex": "\\frac{a}{b}",
|
||||
},
|
||||
{
|
||||
"name": "Quadratic formula",
|
||||
"latex": "x = \\frac{-b \\pm \\sqrt{b^2 - 4ac}}{2a}",
|
||||
},
|
||||
{
|
||||
"name": "Integral",
|
||||
"latex": "\\int_0^\\infty e^{-x^2} dx = \\frac{\\sqrt{\\pi}}{2}",
|
||||
},
|
||||
{
|
||||
"name": "Matrix",
|
||||
"latex": "\\begin{matrix} a & b \\\\ c & d \\end{matrix}",
|
||||
},
|
||||
]
|
||||
|
||||
base_url = "http://localhost:8000/api/v1/convert/latex-to-omml"
|
||||
|
||||
print("Testing OMML Conversion API")
|
||||
print("=" * 80)
|
||||
|
||||
for i, test_case in enumerate(test_cases, 1):
|
||||
print(f"\nTest {i}: {test_case['name']}")
|
||||
print("-" * 80)
|
||||
print(f"LaTeX: {test_case['latex']}")
|
||||
|
||||
try:
|
||||
response = requests.post(
|
||||
base_url,
|
||||
json={"latex": test_case["latex"]},
|
||||
headers={"Content-Type": "application/json"},
|
||||
timeout=10,
|
||||
)
|
||||
|
||||
if response.status_code == 200:
|
||||
result = response.json()
|
||||
omml = result.get("omml", "")
|
||||
|
||||
print(f"✓ Status: {response.status_code}")
|
||||
print(f"OMML length: {len(omml)} characters")
|
||||
print(f"OMML preview: {omml[:150]}...")
|
||||
|
||||
else:
|
||||
print(f"✗ Status: {response.status_code}")
|
||||
print(f"Error: {response.text}")
|
||||
|
||||
except requests.exceptions.RequestException as e:
|
||||
print(f"✗ Request failed: {e}")
|
||||
except Exception as e:
|
||||
print(f"✗ Error: {e}")
|
||||
|
||||
print("\n" + "=" * 80)
|
||||
|
||||
|
||||
def test_invalid_input():
|
||||
"""Test error handling with invalid input."""
|
||||
|
||||
print("\nTesting Error Handling")
|
||||
print("=" * 80)
|
||||
|
||||
base_url = "http://localhost:8000/api/v1/convert/latex-to-omml"
|
||||
|
||||
# Empty LaTeX
|
||||
print("\nTest: Empty LaTeX")
|
||||
response = requests.post(
|
||||
base_url,
|
||||
json={"latex": ""},
|
||||
headers={"Content-Type": "application/json"},
|
||||
)
|
||||
print(f"Status: {response.status_code}")
|
||||
print(f"Response: {response.json()}")
|
||||
|
||||
# Missing LaTeX field
|
||||
print("\nTest: Missing LaTeX field")
|
||||
response = requests.post(
|
||||
base_url,
|
||||
json={},
|
||||
headers={"Content-Type": "application/json"},
|
||||
)
|
||||
print(f"Status: {response.status_code}")
|
||||
print(f"Response: {response.json()}")
|
||||
|
||||
print("\n" + "=" * 80)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
print("OMML API Test Suite")
|
||||
print("Make sure the API server is running on http://localhost:8000")
|
||||
print()
|
||||
|
||||
try:
|
||||
test_latex_to_omml()
|
||||
test_invalid_input()
|
||||
print("\n✓ All tests completed!")
|
||||
|
||||
except KeyboardInterrupt:
|
||||
print("\n\n✗ Tests interrupted by user")
|
||||
except Exception as e:
|
||||
print(f"\n✗ Test suite failed: {e}")
|
||||
Reference in New Issue
Block a user