refactor: implement core and server dir to split the library and endpoints for testing
This commit is contained in:
34
tests/test_server_grade_1.py
Normal file
34
tests/test_server_grade_1.py
Normal 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()
|
||||
Reference in New Issue
Block a user