refactor: implement core and server dir to split the library and endpoints for testing

This commit is contained in:
AlanSilvaaa
2026-05-29 17:43:22 -04:00
parent da59c4e64d
commit 4e9f3c164f
36 changed files with 723 additions and 58 deletions

View File

@@ -0,0 +1,34 @@
import unittest
from fastapi.testclient import TestClient
from math_problems_structure.server.app import app
class Grade1ServerTest(unittest.TestCase):
def test_join_pictures_with_quantity_route_uses_core_generator(self) -> None:
client = TestClient(app)
response = client.post(
"/grade-1/join-pictures-with-quantity",
json={
"available_pictures": [
{
"id": f"picture-{index}",
"name": f"Picture {index}",
"image_path": f"/images/{index}.png",
}
for index in range(10)
],
"seed": 1,
},
)
self.assertEqual(response.status_code, 200)
problem = response.json()
self.assertEqual(len(problem["left_containers"]), 5)
self.assertEqual(len(problem["number_cards"]), 5)
self.assertEqual(len(problem["right_containers"]), 5)
if __name__ == "__main__":
unittest.main()